Currently when I call the program in the terminal without any arguments, it just does a new line with new input.
I was assuming that using the on('*') syntax it would be a default if nothing worked, but this does not seem to be the case.
Is it possible to have a catch all to be able to print something without arguments?
I hope this makes sense. My PR that does not do what I want it to do: https://github.com/DanielMSchmidt/flow-bro/pull/8
Hey @awitherow, I think .command('...', '...', {isDefault: true}) may be the thing you are looking for, see the docs here.
Hmm so with this, it would be necessary to add an isDefault catch to every invocation of the program?
Only with the command('*', {isDefault: true}) I guess
I did this and am not seeing any result. Maybe simply command(''), {isDefault: true}, without the star.
I was just searching how to do this, and found this bug. I've since implemented the following:
.command('*', '', {noHelp: true, isDefault: true})
.action(function(){
program.outputHelp();
});
Now I can run the program with no arguments or invalid arguments and it'll display the help. {noHelp: true} is also good because it means it won't add this argument to the help page.
@mattt416 nice thanks for the research! Will check into implementing it.
A pattern for displaying a default message is now included in the README.
This issue has not had any activity in over six months. It isn't likely to get acted on due to this report.
Feel free to open a new issue if it comes up again, with new information and renewed interest.
Thank you for your contributions.
Most helpful comment
I was just searching how to do this, and found this bug. I've since implemented the following:
Now I can run the program with no arguments or invalid arguments and it'll display the help.
{noHelp: true}is also good because it means it won't add this argument to the help page.