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

Add parent command as prefix of subcommand #980

Merged
merged 5 commits into from Jun 24, 2019

Conversation

shadowspawn
Copy link
Collaborator

@shadowspawn shadowspawn commented Jun 23, 2019

This is a minor rework of #740 to add parent commands into usage help for subcommands:

  • updated to match current code style (lint)
  • fix nested subcommand order, as noted by @simonbuchan

Resolves #739

@shadowspawn shadowspawn changed the title Feature/739 command prefix Add parent command as prefix of subcommand Jun 23, 2019
@shadowspawn shadowspawn added this to the v3.0.0 milestone Jun 23, 2019
@shadowspawn
Copy link
Collaborator Author

Looking for a review before merging from anyone who looked at original PR: @abetomo @simonbuchan @mojavelinux

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.

👍

.name('test')
.command('info [options]')

program.commands[0].helpInformation().should.startWith('Usage: test info [options]')

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.

Copy link
Collaborator Author

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(),

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.

Copy link
Collaborator Author

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.

@shadowspawn
Copy link
Collaborator Author

Thanks @abetomo and @simonbuchan

@shadowspawn shadowspawn merged commit f08adb2 into tj:release/3.0.0 Jun 24, 2019
@shadowspawn shadowspawn deleted the feature/739-command-prefix branch June 24, 2019 07:54
shadowspawn added a commit that referenced this pull request Jun 24, 2019
@shadowspawn shadowspawn added the pending release Merged into a branch for a future release, but not released yet label Jun 26, 2019
@shadowspawn
Copy link
Collaborator Author

Available now as a prerelease. See #1001

@shadowspawn
Copy link
Collaborator Author

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

4 participants