Skip to content
Myr

Omit the help flags from help that are masked by other options (#1247)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent 56221f7 · Browse files · 2 files+38 added−6 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+38 added−6 removed

  • tests:+16 added−0 removed
  • other:+22 added−6 removed

2 files+38 added−6 removed

modified:tests/command.help.test.js+16 added
modified:index.js+22 added-6 removed
1399 unmodified lines
1400 */14011402 optionHelp() {1403 const width = this.padWidth();14041404 const columns = process.stdout.columns || 80;1405 const descriptionWidth = columns - width - 4;1406 function padOptionDetails(flags, description) {1407 return pad(flags, width) + ' ' + optionalWrap(description, descriptionWidth, width + 2);1408 };14091408 // Append the help information1409 return this.options.map((option) => {1410 // Explicit options (including version)1411 const help = this.options.map((option) => {1412 const fullDesc = option.description +1413 ((!option.negate && option.defaultValue !== undefined) ? ' (default: ' + JSON.stringify(option.defaultValue) + ')' : '');1412 return pad(option.flags, width) + ' ' + optionalWrap(fullDesc, descriptionWidth, width + 2);1413 }).concat([pad(this._helpFlags, width) + ' ' + optionalWrap(this._helpDescription, descriptionWidth, width + 2)])1414 .join('\n');1414 return padOptionDetails(option.flags, fullDesc);1415 });14161417 // Implicit help1418 const showShortHelpFlag = this._helpShortFlag && !this._findOption(this._helpShortFlag);1419 const showLongHelpFlag = !this._findOption(this._helpLongFlag);1420 if (showShortHelpFlag || showLongHelpFlag) {1421 let helpFlags = this._helpFlags;1422 if (!showShortHelpFlag) {1423 helpFlags = this._helpLongFlag;1424 } else if (!showLongHelpFlag) {1425 helpFlags = this._helpShortFlag;1426 }1427 help.push(padOptionDetails(helpFlags, this._helpDescription));1428 }14291430 return help.join('\n');1431 };14321433 /**1434 * Return command help documentation.
322 unmodified lines