Skip to content

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

Merged
shadowspawn merged 16 commits intotj:release/8.xfrom
shadowspawn:feature/argument-parseArg
May 3, 2021
Merged

Extend .argument() to add default value and custom parse for command-argument#1508
shadowspawn merged 16 commits intotj:release/8.xfrom
shadowspawn:feature/argument-parseArg

Conversation

@shadowspawn
Copy link
Copy Markdown
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
*/

argumentDescription(argument) {
const extraInfo = [];
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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