From 49ec5204d5e209108922057a05de6fbb3f705859 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 17 Apr 2026 20:38:42 +0200 Subject: [PATCH] fix(ui-cli): resolve --url option collision between global and supervision Rename global --url to --server-url and supervision set-url --url to --supervision-url to prevent Commander option shadowing. Update types, action consumer, integration tests, and README documentation. --- ui/cli/README.md | 6 +++--- ui/cli/src/cli.ts | 2 +- ui/cli/src/commands/action.ts | 2 +- ui/cli/src/commands/supervision.ts | 6 +++--- ui/cli/src/types.ts | 2 +- ui/cli/tests/integration/cli.test.ts | 10 ++++++++-- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/ui/cli/README.md b/ui/cli/README.md index 5b9321d5..6b02186f 100644 --- a/ui/cli/README.md +++ b/ui/cli/README.md @@ -83,7 +83,7 @@ The install script creates a default config file. To override, edit `~/.config/e ### Configuration precedence -Defaults < config file < `--config ` < `--url ` (highest priority). +Defaults < config file < `--config ` < `--server-url ` (highest priority). Use `--config ` to load a specific config file instead of the XDG default. @@ -108,7 +108,7 @@ node dist/cli.js [global-options] [subcommand] [options] | `-V, --version` | Print version | | `-C, --config ` | Path to configuration file | | `--json` | Machine-readable JSON output on stdout | -| `--url ` | WebSocket URL (overrides config host/port/secure) | +| `--server-url ` | WebSocket URL (overrides config host/port/secure) | | `-h, --help` | Show help | ### Commands @@ -195,7 +195,7 @@ node dist/cli.js performance stats # Get performance statistics #### supervision ```shell -node dist/cli.js supervision set-url --url [hashId...] # Set supervision URL +node dist/cli.js supervision set-url --supervision-url [hashId...] # Set supervision URL ``` ### JSON Output Mode diff --git a/ui/cli/src/cli.ts b/ui/cli/src/cli.ts index 355a2716..c1697ae8 100644 --- a/ui/cli/src/cli.ts +++ b/ui/cli/src/cli.ts @@ -23,7 +23,7 @@ program .version(__CLI_VERSION__, '-V, --version', 'output the version number') .option('-C, --config ', 'path to configuration file') .option('--json', 'output results as JSON (machine-readable)', false) - .option('--url ', 'simulator UI server WebSocket URL (overrides config)') + .option('--server-url ', 'simulator UI server WebSocket URL (overrides config)') program.addCommand(createSimulatorCommands(program)) program.addCommand(createStationCommands(program)) diff --git a/ui/cli/src/commands/action.ts b/ui/cli/src/commands/action.ts index 17c1ac6c..9f91ffb4 100644 --- a/ui/cli/src/commands/action.ts +++ b/ui/cli/src/commands/action.ts @@ -25,7 +25,7 @@ export const runAction = async ( const rootOpts = program.opts() const formatter = createFormatter(rootOpts.json) try { - const config = await loadConfig({ configPath: rootOpts.config, url: rootOpts.url }) + const config = await loadConfig({ configPath: rootOpts.config, url: rootOpts.serverUrl }) await executeCommand({ config, formatter, payload, procedureName }) process.exitCode = 0 } catch (error: unknown) { diff --git a/ui/cli/src/commands/supervision.ts b/ui/cli/src/commands/supervision.ts index 782181ec..d4c746a6 100644 --- a/ui/cli/src/commands/supervision.ts +++ b/ui/cli/src/commands/supervision.ts @@ -10,10 +10,10 @@ export const createSupervisionCommands = (program: Command): Command => { cmd .command('set-url [hashIds...]') .description('Set supervision URL for station(s)') - .requiredOption('--url ', 'supervision URL') - .action(async (hashIds: string[], options: { url: string }) => { + .requiredOption('--supervision-url ', 'supervision URL') + .action(async (hashIds: string[], options: { supervisionUrl: string }) => { const payload: RequestPayload = { - url: options.url, + url: options.supervisionUrl, ...buildHashIdsPayload(hashIds), } await runAction(program, ProcedureName.SET_SUPERVISION_URL, payload) diff --git a/ui/cli/src/types.ts b/ui/cli/src/types.ts index 115bc9c8..63ae321d 100644 --- a/ui/cli/src/types.ts +++ b/ui/cli/src/types.ts @@ -1,5 +1,5 @@ export interface GlobalOptions { config?: string json: boolean - url?: string + serverUrl?: string } diff --git a/ui/cli/tests/integration/cli.test.ts b/ui/cli/tests/integration/cli.test.ts index a338f7a3..0c4f8fa0 100644 --- a/ui/cli/tests/integration/cli.test.ts +++ b/ui/cli/tests/integration/cli.test.ts @@ -68,13 +68,19 @@ await describe('evse-cli integration tests', async () => { }) await it('should exit 1 with connection error when no simulator running', async () => { - const result = await runCli(['--url', 'ws://localhost:19999', 'simulator', 'state']) + const result = await runCli(['--server-url', 'ws://localhost:19999', 'simulator', 'state']) assert.strictEqual(result.code, 1) assert.ok(result.stderr.length > 0 || result.stdout.length > 0, 'Expected error output') }) await it('should exit 1 and output JSON error in --json mode when no simulator running', async () => { - const result = await runCli(['--url', 'ws://localhost:19999', '--json', 'simulator', 'state']) + const result = await runCli([ + '--server-url', + 'ws://localhost:19999', + '--json', + 'simulator', + 'state', + ]) assert.strictEqual(result.code, 1) }) -- 2.43.0