First, the cli code as:
const cli = require('commander');
const plugin = require('./commandos/plugin');
cli.
command('plugin [command] [pluginName]').
description(DESCRIPTION.plugin).
action(plugin);
cli.
command('help').
description(DESCRIPTION.help).
action(()=>cli.help());
cli.parse(process.argv);
When I type the command as in terminal:
cli plugin help
it was not run the [plugin] function, I can not get [command] param, it just print help information in the terminal?
it is a bug, right?
Investigating... Yes, bug! I think the behaviour got accidentally introduced in #1018 while fixing help for executable subcommands. A single argument of 'help' will display the help. (The comments show I wondered whether the PR would change the behaviour for action based commands, but incorrectly thought it didn't. Drat!)
To reduce the confusion with your sample program, the help is being displayed using internal code and not through your added help command. You can comment that out and will still get help displayed.
This report has been quite useful, as I am rewriting the help behaviour in #1149 and have been trying to understand the old behaviour. My plan is to only add an implicit help command if there are subcommands and no action handler.
@shadowspawn
Thank you very much for your timely feedback. I am in no hurry to resolve this issue.
This is fixed in the published pre-release of Commander v5.0.0 (#1163)
(I am not planning to fix it in v4 unless someone needs it there.)
Commander v5.0.0 has been released.
@shadowspawn fixed! thanks
Most helpful comment
@shadowspawn
Thank you very much for your timely feedback. I am in no hurry to resolve this issue.