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

Add command short description for global help #898

Closed
jbardon opened this issue Dec 23, 2018 · 3 comments
Closed

Add command short description for global help #898

jbardon opened this issue Dec 23, 2018 · 3 comments

Comments

@jbardon
Copy link

jbardon commented Dec 23, 2018

Hi,
Commands only have one description for now.
This description is used for both automatic global and command help.

program
    .command('test')
    .description(`Description of the command can be very long but it's displayed entirely in the global help`)
    .action(() => { });

Global help:
In a terminal the command description wraps to a second line.
This help purpose is only to have a quick overview not an acurate description.

$ node index.js  -h
Usage: index [options] [command]

Options:
  -h, --help  output usage information

Commands:
  test        Description of the command can be very long but it's displayed entirely in the global help

Command help:

$ node index.js  test -h
Usage: test [options]

Description of the command can be very long but it's displayed entirely in the global help

Options:
  -h, --help  output usage information

I think it might be useful to provide a short description for the global help. The current description would be only used in the command help to provide many details.

What do you think?

@shadowspawn
Copy link
Collaborator

There is support for custom command help so you can expand on the short description like this:

program
    .command('test')
    .description('summary description for global help')
    .action(() => { })
    .on("--help", () => {
        console.log();
        console.log("Description of the command can be very long");
        console.log("and just displayed in the command help");
    });

program.parse(process.argv);
$ node . test --help
Usage: test [options]

summary description for global help

Options:
  -h, --help  output usage information

Description of the command can be very long
and just displayed in the command help

@jbardon
Copy link
Author

jbardon commented Mar 27, 2019

Thanks for your answer.
Using description and --help event does the trick.

The description is still displayed on both the global help and on top of the command help.
And the --help texts appear on the bottom of the command help to provide more details.

@shadowspawn
Copy link
Collaborator

Opened a PR to add .summary() for a short summary to use when listing subcommands.

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

2 participants