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

[BUG] Help output broken for options with falsy default values #855

Closed
plroebuck opened this issue Sep 2, 2018 · 1 comment · Fixed by #856
Closed

[BUG] Help output broken for options with falsy default values #855

plroebuck opened this issue Sep 2, 2018 · 1 comment · Fixed by #856

Comments

@plroebuck
Copy link

plroebuck commented Sep 2, 2018

Description

Help output for options with falsy default values don't show up.

Steps to Reproduce

Save the following script as "commander.spec.js".

#!/usr/bin/env node
var program = require('commander');

function list(val) {
  return val.split(',');
}

program
  .option('-s, --str [value]', 'Specify string value', String, '')
  .option('-l, --list [items]', 'Specify list items', list, [])
  .parse(process.argv);

Make the script executable and invoke it as follows to display help.

$ chmod ugo+x commander.spec.js
$ ./commander.spec.js --help

Expected Behavior

  Usage: commander.spec [options]

  Options:
    -s, --str [value]               Specify string value (default: '')
    -l, --list [items]              Specify list items (default: [])
    -h, --help                      output usage information

Actual Behavior

  Usage: commander.spec [options]

  Options:
    -s, --str [value]               Specify string value (default: )
    -l, --list [items]              Specify list items (default: )
    -h, --help                      output usage information

Version Information

  • OS: macOS 10.13.6 (but verified elsewhere as well)
  • Shell: bash
  • Node: v10.3.0
  • Transpiler: N/A

Additional Information

Where

Command.prototype.optionHelp

Affected releases

v2.12.0 through current (v2.17.1).

Applicable Issues

#122
mochajs/mocha#3433

@abetomo
Copy link
Collaborator

abetomo commented Sep 3, 2018

Thank you for the report. PR was opened.

roman-vanesyan pushed a commit that referenced this issue Sep 15, 2018
@plroebuck plroebuck changed the title [BUG] Help output broken for options with falsey default values [BUG] Help output broken for options with falsy default values Oct 19, 2018
bestlucky0825 pushed a commit to bestlucky0825/commander.js that referenced this issue Jun 1, 2022
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

Successfully merging a pull request may close this issue.

2 participants