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

Is there a way to show global options in subcommand help? #1689

Closed
nitzano opened this issue Feb 7, 2022 · 3 comments
Closed

Is there a way to show global options in subcommand help? #1689

nitzano opened this issue Feb 7, 2022 · 3 comments

Comments

@nitzano
Copy link

nitzano commented Feb 7, 2022

import { Command } from 'commander';

const subCommand = new Command('sub').option('-s1 --sub1', 'sub option')

const globalCommand = new Command('global');

globalCommand 
	.description('global command')
	.option('-g1 --global1', 'global option')
	.addCommand(subCommand)

Is there a way to show -g1 exists when running global sub --help? (which shows only -s1 )

I know I can use optsWithGlobals() inside the action but was wondering if there is an option to also show
in the subcommand's help the existance of it's global options from the parent command(s)?

Thanks :)

@shadowspawn
Copy link
Collaborator

There is not an option to include the global options in the subcommand help.

(It didn't rate as high as I expected in a poll last year: #1551 (comment))

@nitzano
Copy link
Author

nitzano commented Feb 7, 2022

Thanks @shadowspawn, if there is a way to vote for this feature again I'd be happy to give my +1

@shadowspawn
Copy link
Collaborator

Added showGlobalOptions in Commander 9.5.0.

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

No branches or pull requests

2 participants