Skip to content

Provide Array of permitted values for an option. #518

@joshuapinter

Description

@joshuapinter

I have an .option() that is only allowed to be one of "all", "debug" or "none".

I'd like an easy way to pass an Array to an option() and have Commander automatically check that the value passed by the user is one of the permitted values.

Something like this:

.option('-t, --target <target>', 'Specifies the target.', ["all", "debug", "none"])

Also including the permitted values in the help output could be useful, provided it's not a very large Array.

I'd gladly do the PR if I can get a response from @tj or a collaborator that this is useful.

Thanks!!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions