Commander.js: Impossible to customise descriptions of --help and --version options

Created on 3 Dec 2015  路  8Comments  路  Source: tj/commander.js

Say I wanted to use a different wording for the --version or --help options in the auto-generated help output:

program
    .version("0.0.1")
    .option("-p, --peppers",   "Add peppers")
    .option("-P, --pineapple", "Add pineapple")
    .option("-c, --cheese",    "Add cheese")
    .option("-h, --help",      "Display this help message and exit")
    .option("-V, --version",   "Display the version of the running program")

... I can't. Specifying --help prevents the --help option from even doing anything, and specifying --version just duplicates the option in the --help output:

  Usage: index [options]

  Options:

    -h, --help       output usage information
    -V, --version    output the version number
    -p, --peppers    Add peppers
    -P, --pineapple  Add pineapple
    -c, --cheese     Add cheese
    -V, --version    Display the version of the running program

Shouldn't there be a way of overriding those two option descriptions? Some users might wish to use a different wording, or at least correct the capitalisation.

Most helpful comment

Support for customising the version and help descriptions has shipped in v3 (thanks @idmontie): https://github.com/tj/commander.js/releases/tag/v3.0.0

All 8 comments

This is probably never gonna be looked-at, if this package's recent traction is anything to go by.

Have taken it upon myself to develop a simpler and more hands-on alternative instead:
https://www.npmjs.com/package/get-options

Thanks anyway. =) Will leave this open in case somebody does feel like it warrants actioning.

+1

You could always do:

var Command = require('commander').Command;

Command.prototype.helpInformation = function() {
    return "My help information!!"
};

/* Do stuff with Command */

Haha, maybe. :D

Too late now, though. Really happy with how this turned out. =)

Duplicate of #471 . Think we'll have to check out your project :-) This is just way too buggy.

This issue has not had any activity in over six months. It isn't likely to get acted on due to this report.

The issue author has done their own approach, and there are other issues covering this area such as #47.

Feel free to open a new issue if it comes up again, with new information and renewed interest.

Thank you for your contributions.

This issue will be resolved when v3.0.0 is released. Available now as a prerelease. See #1001

Support for customising the version and help descriptions has shipped in v3 (thanks @idmontie): https://github.com/tj/commander.js/releases/tag/v3.0.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FerencH picture FerencH  路  4Comments

0505gonzalez picture 0505gonzalez  路  3Comments

hossamelmansy picture hossamelmansy  路  4Comments

shadowspawn picture shadowspawn  路  3Comments

cmoulliard picture cmoulliard  路  4Comments