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

Support argument processing without action handler #1529

Merged

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented May 25, 2021

Pull Request

Problem

The new processing of arguments is also useful in a single command program without an action handler, but
argument defaults and custom processing and choices were only being applied if there was an action handler.

Prompted by realising .choices() would not work without action handler.

Solution

Refactor and process command-arguments whether or not action handler.

When adding the functionality in #1508 I had decided that I preferred not to modify this.args with processed results.
Save processed arguments as this.processedArgs so accessible for simple program without action handler, and from the new hook support too.

This PR includes some minor other improvements:

  • added .arg to Command constructor
  • initialise .arg to empty array (matches existing TypeScript declaration)
  • add JSDoc types for some key Command properties

Changelog

  • Changed: Command property .arg initialised to empty array (was previously undefined)

@shadowspawn shadowspawn marked this pull request as ready for review May 27, 2021 07:50
@shadowspawn shadowspawn added this to the v8.0.0 milestone May 29, 2021
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.

👍

@shadowspawn
Copy link
Collaborator Author

Thanks @abetomo

@shadowspawn shadowspawn merged commit 4663597 into tj:release/8.x Jun 2, 2021
@shadowspawn shadowspawn deleted the feature/arguments-without-action-2 branch June 2, 2021 08:01
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Jun 2, 2021
@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.

2 participants