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

Extend .argument() to add default value and custom parse for command-argument #1508

Merged
merged 16 commits into from
May 3, 2021

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Apr 21, 2021

Pull Request

Problem

Follow through with the idea that .argument() follow same pattern as .option(), with support for default value (for optional arguments) and custom command-argument parsing.

Solution

Support for default value (for optional arguments) and custom command-argument parsing.

Implementation notes:

  • not emitting events for the arguments
  • only processing the arguments for the action handler, not for program.args
  • custom processing for arguments uses same style function as for options

ChangeLog

  • add default value for optional command-arguments
  • add custom processing function for command-arguments
  • deprecate InvalidOptionArgumentError (replaced by InvalidArgumentError)
  • CommanderError code commander.invalidOptionArgument renamed commander.invalidArgument

@shadowspawn shadowspawn marked this pull request as ready for review April 30, 2021 04:00
@@ -258,6 +258,13 @@ class Help {
*/

argumentDescription(argument) {
const extraInfo = [];
Copy link
Collaborator

Choose a reason for hiding this comment

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

extraInfo appears to have only 0 or 1 elements.
Does it need to be an array?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair question. No, does not need to be an array currently. However, I left in the array as planning to add choices, like optionDescription which I copied the code from.

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
Copy link
Collaborator Author

Thanks @abetomo

@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label May 3, 2021
@shadowspawn shadowspawn added this to the v8.0.0 milestone May 3, 2021
@shadowspawn shadowspawn merged commit f99d6fa into tj:release/8.x May 3, 2021
@shadowspawn shadowspawn deleted the feature/argument-parseArg branch May 3, 2021 07:45
@shadowspawn shadowspawn removed the pending release Merged into a branch for a future release, but not released yet label Jun 25, 2021
kevinoid added a commit to kevinoid/noderegression that referenced this pull request Jan 31, 2022
InvalidOptionArgumentError was renamed to InvalidArgumentError in
tj/commander.js#1508 for commander@8.0.0.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/hub-ci-status that referenced this pull request Jan 31, 2022
InvalidOptionArgumentError was renamed to InvalidArgumentError in
tj/commander.js#1508 for commander@8.0.0.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/swagger-spec-validator that referenced this pull request Jan 31, 2022
InvalidOptionArgumentError was renamed to InvalidArgumentError in
tj/commander.js#1508 for commander@8.0.0.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/fetch-procore-api-docs that referenced this pull request Jan 31, 2022
InvalidOptionArgumentError was renamed to InvalidArgumentError in
tj/commander.js#1508 for commander@8.0.0.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/node-project-template that referenced this pull request Jan 31, 2022
InvalidOptionArgumentError was renamed to InvalidArgumentError in
tj/commander.js#1508 for commander@8.0.0.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
kevinoid added a commit to kevinoid/procore-docs-to-openapi that referenced this pull request May 6, 2022
InvalidOptionArgumentError was renamed to InvalidArgumentError in
tj/commander.js#1508 for commander@8.0.0.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
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.

2 participants