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

Global options not displayed in sub-command help #1078

Closed
jjs105 opened this issue Oct 15, 2019 · 5 comments
Closed

Global options not displayed in sub-command help #1078

jjs105 opened this issue Oct 15, 2019 · 5 comments

Comments

@jjs105
Copy link

jjs105 commented Oct 15, 2019

I may be missing something but is there any way to include the global options information in the sub-command help.

Test Code:

program
  .description('Test program/command.')
  .option('-g, --global', 'a global option')
  .version(VERSION);

program
  .command('sub')
  .description('Sub-command!')
  .option('-l, --local', 'a sub-command local option')
  .action(() => {});

program.parse(process.argv);

Program Help Output:

$> node test.js -h
Usage: test [options] [command]

Test program/command.

Options:
  -g, --global   a global option
  -V, --version  output the version number
  -h, --help     output usage information

Commands:
  sub [options]  Sub-command!

Sub-Command Help Output:

$> node test.js sub -h
Usage: test sub [options]

Sub-command!

Options:
  -l, --local  a sub-command local option
  -h, --help   output usage information

What I would want/expect:

$> node test.js sub -h
Usage: test sub [options]

Sub-command!

Options:
  -g, --global   a global option
  -V, --version  output the version number
  -l, --local  a sub-command local option
  -h, --help   output usage information
@shadowspawn
Copy link
Collaborator

You didn't miss anything, there is not a way to include the global options information in the sub-command help.

@shadowspawn
Copy link
Collaborator

Related: #905

@shadowspawn
Copy link
Collaborator

An answer was provided, and no further activity or likes in a few months.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

@shadowspawn
Copy link
Collaborator

Opened poll on possible enhancements to global options: #1551

@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