-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add parent command as prefix of subcommand #980
Add parent command as prefix of subcommand #980
Conversation
- fix multiple parent order (although multiple levels not yet supported) - without using any new javascript features
Looking for a review before merging from anyone who looked at original PR: @abetomo @simonbuchan @mojavelinux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
.name('test') | ||
.command('info [options]') | ||
|
||
program.commands[0].helpInformation().should.startWith('Usage: test info [options]') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to have a nested command test too, if that's explicitly being handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nested commands are not currently supported! But since the code included a loop, I thought it should do it right for the possible future. :-)
var usage = [ | ||
'Usage: ' + cmdName + ' ' + this.usage(), | ||
'Usage: ' + parentCmdNames + cmdName + ' ' + this.usage(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit, you can shorten this by having the loop above mutate cmdName
instead of , since it's not used below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I did wonder about that too, but went for long and clear.
Thanks @abetomo and @simonbuchan |
Available now as a prerelease. See #1001 |
Shipped in v3: https://github.com/tj/commander.js/releases/tag/v3.0.0 |
This is a minor rework of #740 to add parent commands into usage help for subcommands:
Resolves #739