Skip to content

Main help output doesn't show custom usage of commands #1885

@yume-chan

Description

@yume-chan

Version: "commander": "^10.0.1",

There are several cases I'm using the .usage() option:

  • When a command only has limited number of options, I want to display all of them in usage, instead of [options]

    program
        .command("devices")
        .usage("[-l]")
        .option("-l", "long output", false)
  • When a command requires -- before arguments because otherwise commander parses them as options

    program
        .command("shell [args...]")
        .description(
            "run remote shell command (interactive shell if no command given). `--` is required before command name."
        )
        .usage("[options] [-- <args...>]")

It's working in each command's individual help message, like

> node .\esm\index.js help devices
Usage: tango-cli devices [-l]

Options:
  -l          long output (default: false)
  -h, --help  display help for command

But not in the main help

> node .\esm\index.js help
Usage: tango-cli [options] [command]

Options:
  -H <host>                  name of adb server host (default: "127.0.0.1")
  -P <port>                  port of adb server (default: 5037)
  -h, --help                 display help for command

Commands:
  devices [options]
  shell [options] [args...]  run remote shell command (interactive shell if no       
                             command given). `--` is required before command name.   
  help [command]             display help for command

In particular the second case might confuse the users if they don't know help [command] will display a different usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsREADME (or other docs) could be improved

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions