Skip to content
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

No help printed for command options #618

Closed
wallali opened this issue Apr 8, 2017 · 7 comments
Closed

No help printed for command options #618

wallali opened this issue Apr 8, 2017 · 7 comments

Comments

@wallali
Copy link

wallali commented Apr 8, 2017

  const program = require('commander');
...
  program.command('stats <file>')
    .description('Print stats for the conversation file')
    .option('-s, --single', 'Print on a single line')
    .action(play);
...
  Usage: mytool [options] [command]


  Commands:

    stats [options] <file>  Print stats for the conversation file

  Options:

    -h, --help     output usage information
    -V, --version  output the version number

I can't get it to print any help for the stats command, the -s option is not printed in the help.
mytool help stats prints nothing

@wallali
Copy link
Author

wallali commented Apr 8, 2017

  program.command('stats <file>', {})
    .description('Print stats for the conversation file')
    .option('-s, --single', 'Print on a single line')
    .action(play);

using {} causes the -s to be printed but in the incorrect spot, not with the command help but with the overall help.

 Usage: mytool [options] [command]


  Commands:

    stats <file>  [object Object]
    help [cmd]    display help for [cmd]

  Print stats for the conversation file

  Options:

    -h, --help     output usage information
    -V, --version  output the version number
    -s, --single   Print on a single line

@jphager2
Copy link

@wallali did you figure this out?

@jsamr
Copy link
Contributor

jsamr commented Oct 11, 2017

Same issue for me.

@channg
Copy link

channg commented Jul 23, 2018

try the mytool stats -h

@Oblongmana
Copy link

Bump - still not working

@shadowspawn
Copy link
Collaborator

I have not looked into the undocumented help command, but -h and --help will display the help for a command if it has an action handler (as noted by @channg).

const program = require("commander");

program.command('stats <file>')
    .description('Print stats for the conversation file')
    .option('-s, --single', 'Print on a single line')
    .action((fileArgument, cmd) => {
        console.log(fileArgument);
    });

program.parse(process.argv);
$ node index.js stats -h
Usage: stats [options] <file>

Print stats for the conversation file

Options:
  -s, --single  Print on a single line
  -h, --help    output usage information
$ node index.js -h
Usage: index [options] [command]

Options:
  -h, --help              output usage information

Commands:
  stats [options] <file>  Print stats for the conversation file

@shadowspawn
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants