Skip to content

Commit a5cd31d

Browse files
authored
Merge pull request #298 from Azure/copilot/fix-cli-flag-case-sensitivity
Support lowercase `-v` as a version flag alias
2 parents 507de32 + 7039346 commit a5cd31d

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎docs/getting-started.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Verify the installation:
2727
apiops --version
2828
```
2929

30+
The short flags `-v` and `-V` also print the installed CLI version.
31+
3032
---
3133

3234
## 1. Extract APIM Configuration

‎src/cli/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const program = new Command();
2121
program
2222
.name('apiops')
2323
.version(packageJson.version)
24+
.version(packageJson.version, '-v')
2425
.description('CLI tool for Azure API Management configuration-as-code');
2526

2627
// Show global options in subcommand help (e.g. apiops extract --help)

‎tests/unit/cli/index.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,18 @@ async function getPackageVersion(): Promise<string> {
3333
}
3434

3535
describe('CLI entry point', () => {
36-
it('should display version with --version', async () => {
37-
const [result, expectedVersion] = await Promise.all([runCli(['--version']), getPackageVersion()]);
36+
it.each(['--version', '-V', '-v'])('should display version with %s', async (flag) => {
37+
const [result, expectedVersion] = await Promise.all([runCli([flag]), getPackageVersion()]);
3838
expect(result.stdout.trim()).toBe(expectedVersion);
39+
expect(result.stderr).toBe('');
3940
expect(result.exitCode).toBe(0);
4041
}, 15_000);
4142

4243
it('should display help with --help', async () => {
4344
const result = await runCli(['--help']);
4445
expect(result.stdout).toContain('apiops');
46+
expect(result.stdout).toContain('-V, --version');
47+
expect(result.stdout).toMatch(/-v\s+output the version number/);
4548
expect(result.stdout).toContain('--log-level');
4649
expect(result.stdout).toContain('--format');
4750
expect(result.stdout).toContain('--subscription-id');

0 commit comments

Comments
 (0)