commander.js icon indicating copy to clipboard operation
commander.js copied to clipboard

The root `--help` doesn't respect `.usage()` in a command

Open samcx opened this issue 2 years ago • 2 comments

Example

.usage('[directory] [options]')

CleanShot 2024-02-07 at 17 39 20@2x

Let me know if I'm missing something here!

On the latest version v12.

samcx avatar Feb 08 '24 01:02 samcx

This is historical behaviour (which I am still wondering whether to change).

You can configure the help so the subcommand list displays your custom usage.

Example file: help-subcommands-usage.js

program.configureHelp({ subcommandTerm: (cmd) => cmd.name() + ' ' + cmd.usage() });

Related: #1853 #1885

shadowspawn avatar Feb 09 '24 09:02 shadowspawn

@shadowspawn Thank you for the confirmation!

Given how things are nicely updated in the root help output (e.g., description()) when things are updated in a subcommand, I was expecting it to also change for usage(), so maybe it would be a nice change for consistency!

samcx avatar Feb 09 '24 20:02 samcx