diff --git a/sources/constants.ts b/sources/constants.ts index 61eb0c1..b8a5131 100644 --- a/sources/constants.ts +++ b/sources/constants.ts @@ -14,7 +14,7 @@ export enum NodeType { export const HELP_COMMAND_INDEX = -1; export const HELP_REGEX = /^(-h|--help)(?:=([0-9]+))?$/; -export const OPTION_REGEX = /^(--[a-z]+(?:-[a-z]+)*|-[a-zA-Z]+)$/; +export const OPTION_REGEX = /^(--[a-z]+(?:-[a-z]+)*|-[a-z]+)$/i; export const BATCH_REGEX = /^-[a-zA-Z]{2,}$/; export const BINDING_REGEX = /^([^=]+)=([\s\S]*)$/; diff --git a/tests/specs/advanced.test.ts b/tests/specs/advanced.test.ts index b638b00..da31527 100644 --- a/tests/specs/advanced.test.ts +++ b/tests/specs/advanced.test.ts @@ -123,6 +123,22 @@ describe(`Advanced`, () => { expect(await runCli(cli, [`--help`])).toEqual(cli.usage(null)); }); + it(`should support camelCase in parameter name`, async () => { + expect.assertions(1); + const cli = new Cli(); + + class CommandA extends Command { + camelCase = Option.String(`--camelCase`); + async execute() { + expect(this.camelCase).toBe(`foo`); + } + } + + cli.register(CommandA); + + await runCli(cli, [`--camelCase=foo`]); + }); + it(`should print the general help if there are documented named commands apart the default one`, async () => { const cli = new Cli(); cli.register(Builtins.HelpCommand);