As per the commander.js readme, I can specify the default command thus:
var program = ...;
program
...
.command('list', 'list packages installed', {isDefault: true})
.parse(process.argv);
In my application, I'm using the .command()
without the description parameter, for using .action()
. I tried passing the second param null
and the third option with the isDefault:true
. But it does not seem to work:
program.command('help', null, {isDefault:true})
.description('display help information.')
.action(function(){
program.outputHelp();
});
How do I pass isDefault:true
to a command with .action()
?
according to the documentation:
When .command() is invoked with a description argument, no .action(callback) should be called to handle sub-commands, otherwise there will be an error.
I believe this means that you will need to find a workaround, such as writing a separate subcommand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With