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

Choices for arguments #1525

Merged
merged 5 commits into from May 26, 2021
Merged

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented May 21, 2021

Pull Request

Problem

We have .choices() for options but not for arguments.

Issue: #1458
Past issue: #971

Solution

Follow same pattern as Option with the new Argument class, and add .choices().

program
  .addArgument(new Argument('color').choices(['red', 'blue']))
$ node example.js purple
error: command-argument value 'purple' is invalid for argument 'color'. Allowed choices are red, blue.

Includes some tests and typings for .default() and .argParser() that got missed.

ChangeLog

@shadowspawn shadowspawn added this to the v8.0.0 milestone May 21, 2021
@shadowspawn shadowspawn force-pushed the feature/argument-choices branch from 75de35b to b47afa5 Compare May 25, 2021
@shadowspawn shadowspawn marked this pull request as ready for review May 25, 2021
@shadowspawn
Copy link
Collaborator Author

shadowspawn commented May 25, 2021

Rebased onto release/8.x.

Copy link
Collaborator

@abetomo abetomo left a comment

LGTM!

@shadowspawn shadowspawn merged commit 708527e into tj:release/8.x May 26, 2021
12 checks passed
@shadowspawn shadowspawn added the pending release label May 26, 2021
@shadowspawn shadowspawn deleted the feature/argument-choices branch Jun 2, 2021
@shadowspawn shadowspawn removed the pending release label Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants