New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Commander always executes the first registered command #825
Comments
The problem seems to happen when you put a description to a command, try to remove them |
Here, all my options are started.
something1() is started, then something2(), ... I cant figure out why and I already removed my descriptions.. |
You are invoking the actions yourself instead of passing them as reference. Try |
I ran into the same issue today, I now use the
|
To expand on the answer to the original question... Adding a description parameter to https://github.com/tj/commander.js#git-style-sub-commands To add a description without switching modes, use |
To expand on answer to @mpathy issue:
https://github.com/tj/commander.js#examples So your code could look like: program.command("init").action(() => {
something1();
});
program.command("install").action(() => {
something2();
});
program.command("uninstall").action(() => {
something3();
}); |
An answer was provided, and no further activity in a month. Closing this as resolved. Feel free to open a new issue if it comes up again, with new information and renewed interest. |
I have a small script in which I'm trying to use commander.js for parsing options but I'm having some trouble understanding how its supposed to be used. Looking at the docs I assume I have set it up correctly, but no matter what input I try running it with it always executes the action for the first registered command.
Script:
If I try running the script with
./index.js init
, it attempts to invoke thebuild
command. Similarly if I reverse the order of registering the commands and try to invokebuild
, it executes theinit
command.Using the latest commander.js 2.16.0 from npm, running on Ubuntu 16.04 with node v8.11.2 using fish shell. I also tried using bash with the same result.
This is the result of simply logging
process.argv
:The text was updated successfully, but these errors were encountered: