-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Help doesn't work when using subcommands #110
Comments
@andzdroid Just hit this problem, found out the cause and a fix. You need to change your .parse() line. Don't chain it off of the previous lines, it'll chain off of the .command() instance. Directly use it as |
@damianb can you show an example of how you got that working? |
change your last line, in your own example, to literally be Don't chain it at all. |
I have:
Still shows the --help option but calling it results in:
|
@andrew In practice, works for me - working example: https://github.com/damianb/blip/blob/master/bin/blip |
@damianb Thanks, I ended up doing this: https://github.com/andrew/nodecopter/blob/bb1246457145a61d8be2ef99c5058c9818377e2f/bin/nodecopter |
I had the same problem but the following code works for me var program = require('commander');
program
.version('0.0.1');
program
.command('test [name]')
.description('test command')
.action((name, cmd) => {
...
});
program
.parse(process.argv); |
Very simple test program:
Save it as bla.js.
If we run
node bla -h
, we get this error:Similar results if we use
--help
.-V
and--version
work fine though.I'm okay with it not working, since we can use
bla help [cmd]
, but the help message lists -h and --help as options, and there is no way to turn that off.The text was updated successfully, but these errors were encountered: