You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When there are global common options on the program, and subcommands using action handlers, there are options in two places. In a simple program you may have easy access to both the "program" and the "command", but that pattern is not always convenient, and does not scale very well to nested subcommands or to the action handler being passed just options.
Current:
program
.option('-g,--global')
.command('sub')
.option('-l,--local')
.action((cmd) => {
console.log(program.global); // using program
console.log(cmd.parent.global)); // using parent
console.log(cmd.local);
});
Possible Solution
@a-fas offered a routine or an option to .opt() to collect all the options: #1024 (comment)
Enhancing .opts() is a nice idea. Adding this issue to make it visible as a possible enhancement.
shadowspawn
changed the title
Add way to get inherited/global options from parents
Add way to collect inherited/global options from parents
Jan 23, 2020
Problem
When there are global common options on the program, and subcommands using action handlers, there are options in two places. In a simple program you may have easy access to both the "program" and the "command", but that pattern is not always convenient, and does not scale very well to nested subcommands or to the action handler being passed just options.
Current:
Possible Solution
@a-fas offered a routine or an option to
.opt()
to collect all the options:#1024 (comment)
Enhancing
.opts()
is a nice idea. Adding this issue to make it visible as a possible enhancement.e.g. trying some wording:
The text was updated successfully, but these errors were encountered: