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 marked this pull request as ready for review May 25, 2021 06:20
@shadowspawn
Copy link
Collaborator Author

Rebased onto release/8.x.

Copy link
Collaborator

@abetomo abetomo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@shadowspawn shadowspawn merged commit 708527e into tj:release/8.x May 26, 2021
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label May 26, 2021
@shadowspawn shadowspawn deleted the feature/argument-choices branch June 2, 2021 08:08
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet 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