Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow upper case in parameter name #168

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sources/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]*)$/;

Expand Down
16 changes: 16 additions & 0 deletions tests/specs/advanced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading