Skip to content

Bug in regex for lone short flag #2227

@sorawee

Description

@sorawee

#1256 added a support for lone short flag.

Unfortunately, this only works correctly on short flags with one character. Short flags with multiple characters (Java-style short flags) will incorrectly create incorrect field names. For example, .option('-name') will result in a field Name, which is not in camelCase.

The reason is that this regex only matches a short flag with one character. This means a short flag with multiple characters will be categorized as a long flag. Consequently, Commander.js attempts to strip -- from -name, which is a no-op, resulting in -name. Then, the camel case conversion of -name results in Name, which is not a camel case as intended.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions