Skip to content

Poll: Enhancements to global options #1551

Closed
@shadowspawn

Description

@shadowspawn

Commander supports global options by declaring them on the program. This is flexible, but Commander does not offer any additional support to make them easier to use as a programmer or find them as a user. Example program with current behaviour:

program
  .option('-g, --global');

program.command('sub')
  .option('-l, --local')
  .action((options, sub) => {
    console.log('subcommand options: %o', options);
    console.log('global options: %o', program.opts());
  });

program.parse();
$ node example.js --global sub --local
subcommand options: { local: true }
global options: { global: true }
$  node example.js help sub
Usage: example sub [options]

Options:
  -l, --local
  -h, --help   display help for command

Related: #243 #476 #905 #1024 (comment) #1078 #1426 #1631

What additional support would you like? (I am wondering what is most popular and useful, not planning to add everything!)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions