Configure Help option with commad that takes one argument in node commander

56 views Asked by At

How to configure help option the command in node commander that takes one argument.
Like, I have one command to add-repository as below:

program
  .command('add-repository <repo-name>')
  .option('-h,--help','help add-repository command')
  .description('configure your repository to do the respository specific taks')
  .action(addRepoCommandHandler);

Currently I can call the command by specifying the argument and it is working fine. I want to add one option to add help option. That will show the help text when user calls the command with -h or --help option like: add-repository --help.

1

There are 1 answers

1
shadowspawn On BEST ANSWER

By default every command has a help option. So just take out your own help option and try using the one Commander adds for you.

You may change the default help flags and description using .helpOption().

(Disclaimer: I am a maintainer of Commander.)