From: Jérôme Benoit Date: Wed, 22 Apr 2026 19:58:21 +0000 (+0200) Subject: feat(cli): expose station identity overrides and CSMS credentials X-Git-Tag: v4.5~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e93c0aee3d488fb814ea32567325cb8d983e14fe;p=e-mobility-charging-stations-simulator.git feat(cli): expose station identity overrides and CSMS credentials Add --base-name, --fixed-name, --name-suffix, --supervision-user and --supervision-password options to station add command. Add credential options to supervision set-url. Update integration tests and README. --- diff --git a/ui/cli/README.md b/ui/cli/README.md index 0b7c663d..05bcfd49 100644 --- a/ui/cli/README.md +++ b/ui/cli/README.md @@ -152,14 +152,19 @@ evse-cli station delete [hashId...] # Delete station(s) **`station add` options:** -| Option | Required | Description | -| ------------------------- | -------- | ------------------------------------ | -| `-t, --template ` | Yes | Station template name | -| `-n, --count ` | Yes | Number of stations to add | -| `--supervision-url ` | No | Override supervision URL | -| `--auto-start` | No | Auto-start added stations | -| `--persistent-config` | No | Enable persistent OCPP configuration | -| `--ocpp-strict` | No | Enable OCPP strict compliance | +| Option | Required | Description | +| ----------------------------------- | -------- | ------------------------------------------ | +| `-t, --template ` | Yes | Station template name | +| `-n, --count ` | Yes | Number of stations to add | +| `--auto-start` | No | Auto-start added stations | +| `--base-name ` | No | Override template base name for station id | +| `--fixed-name` | No | Use base name verbatim as station id | +| `--name-suffix ` | No | Suffix appended to derived station id | +| `--ocpp-strict` | No | Enable OCPP strict compliance | +| `--persistent-config` | No | Enable persistent OCPP configuration | +| `--supervision-password ` | No | CSMS basic auth password | +| `--supervision-url ` | No | Override supervision URL | +| `--supervision-user ` | No | CSMS basic auth user | **`station delete` options:** @@ -248,7 +253,7 @@ When `-p` is provided, version detection is skipped and the raw payload is passe #### supervision ```shell -evse-cli supervision set-url --supervision-url [hashId...] # Set supervision URL +evse-cli supervision set-url --supervision-url [--supervision-user ] [--supervision-password ] [hashId...] # Set supervision URL ``` #### performance diff --git a/ui/cli/src/commands/station.ts b/ui/cli/src/commands/station.ts index c7d10428..3e029c48 100644 --- a/ui/cli/src/commands/station.ts +++ b/ui/cli/src/commands/station.ts @@ -35,26 +35,41 @@ export const createStationCommands = (program: Command): Command => { .description('Add stations from template') .requiredOption('-t, --template ', 'station template name') .requiredOption('-n, --count ', 'number of stations to add', parseInteger) - .option('--supervision-url ', 'supervision URL for new stations') .option('--auto-start', 'auto-start added stations') - .option('--persistent-config', 'enable persistent OCPP configuration') + .option('--base-name ', 'override template base name for station id') + .option('--fixed-name', 'use base name verbatim as station id') + .option('--name-suffix ', 'suffix appended to derived station id') .option('--ocpp-strict', 'enable OCPP strict compliance') + .option('--persistent-config', 'enable persistent OCPP configuration') + .option('--supervision-password ', 'CSMS basic auth password') + .option('--supervision-url ', 'supervision URL for new stations') + .option('--supervision-user ', 'CSMS basic auth user') .action( async (options: { autoStart?: true + baseName?: string count: number + fixedName?: true + nameSuffix?: string ocppStrict?: true persistentConfig?: true + supervisionPassword?: string supervisionUrl?: string + supervisionUser?: string template: string }) => { const payload: RequestPayload = { numberOfStations: options.count, options: pickDefined(options as Record, { autoStart: 'autoStart', + baseName: 'baseName', + fixedName: 'fixedName', + nameSuffix: 'nameSuffix', ocppStrict: 'ocppStrictCompliance', persistentConfig: 'persistentConfiguration', + supervisionPassword: 'supervisionPassword', supervisionUrl: 'supervisionUrls', + supervisionUser: 'supervisionUser', }) as RequestPayload, template: options.template, } diff --git a/ui/cli/src/commands/supervision.ts b/ui/cli/src/commands/supervision.ts index d4c746a6..57962819 100644 --- a/ui/cli/src/commands/supervision.ts +++ b/ui/cli/src/commands/supervision.ts @@ -2,7 +2,7 @@ import { Command } from 'commander' import { ProcedureName, type RequestPayload } from 'ui-common' import { runAction } from './action.js' -import { buildHashIdsPayload } from './payload.js' +import { buildHashIdsPayload, pickDefined } from './payload.js' export const createSupervisionCommands = (program: Command): Command => { const cmd = new Command('supervision').description('Supervision URL management') @@ -11,13 +11,28 @@ export const createSupervisionCommands = (program: Command): Command => { .command('set-url [hashIds...]') .description('Set supervision URL for station(s)') .requiredOption('--supervision-url ', 'supervision URL') - .action(async (hashIds: string[], options: { supervisionUrl: string }) => { - const payload: RequestPayload = { - url: options.supervisionUrl, - ...buildHashIdsPayload(hashIds), + .option('--supervision-password ', 'CSMS basic auth password') + .option('--supervision-user ', 'CSMS basic auth user') + .action( + async ( + hashIds: string[], + options: { + supervisionPassword?: string + supervisionUrl: string + supervisionUser?: string + } + ) => { + const payload: RequestPayload = { + url: options.supervisionUrl, + ...pickDefined(options as Record, { + supervisionPassword: 'supervisionPassword', + supervisionUser: 'supervisionUser', + }), + ...buildHashIdsPayload(hashIds), + } + await runAction(program, ProcedureName.SET_SUPERVISION_URL, payload) } - await runAction(program, ProcedureName.SET_SUPERVISION_URL, payload) - }) + ) return cmd } diff --git a/ui/cli/tests/integration/cli.test.ts b/ui/cli/tests/integration/cli.test.ts index 0c4f8fa0..6d798a8d 100644 --- a/ui/cli/tests/integration/cli.test.ts +++ b/ui/cli/tests/integration/cli.test.ts @@ -88,4 +88,27 @@ await describe('evse-cli integration tests', async () => { const result = await runCli(['station', 'add']) assert.strictEqual(result.code, 1) }) + + await it('should show identity and credential options in station add help', async () => { + const result = await runCli(['station', 'add', '--help']) + assert.strictEqual(result.code, 0) + assert.ok(result.stdout.includes('--base-name'), 'Expected --base-name option') + assert.ok(result.stdout.includes('--fixed-name'), 'Expected --fixed-name option') + assert.ok(result.stdout.includes('--name-suffix'), 'Expected --name-suffix option') + assert.ok(result.stdout.includes('--supervision-user'), 'Expected --supervision-user option') + assert.ok( + result.stdout.includes('--supervision-password'), + 'Expected --supervision-password option' + ) + }) + + await it('should show credential options in supervision set-url help', async () => { + const result = await runCli(['supervision', 'set-url', '--help']) + assert.strictEqual(result.code, 0) + assert.ok(result.stdout.includes('--supervision-user'), 'Expected --supervision-user option') + assert.ok( + result.stdout.includes('--supervision-password'), + 'Expected --supervision-password option' + ) + }) })