* You can pass in flags and a description to customise the built-in help option. * Pass in false to disable the built-in help option. * * @example * program.helpOption('-?, --help' 'show help'); // customise * program.helpOption(false); // disable * * @param {(string | boolean)}
(flags, description)
| 2571 | */ |
| 2572 | |
| 2573 | helpOption(flags, description) { |
| 2574 | // Support enabling/disabling built-in help option. |
| 2575 | if (typeof flags === 'boolean') { |
| 2576 | if (flags) { |
| 2577 | if (this._helpOption === null) this._helpOption = undefined; // reenable |
| 2578 | if (this._defaultOptionGroup) { |
| 2579 | // make the option to store the group |
| 2580 | this._initOptionGroup(this._getHelpOption()); |
| 2581 | } |
| 2582 | } else { |
| 2583 | this._helpOption = null; // disable |
| 2584 | } |
| 2585 | return this; |
| 2586 | } |
| 2587 | |
| 2588 | // Customise flags and description. |
| 2589 | this._helpOption = this.createOption( |
| 2590 | flags ?? '-h, --help', |
| 2591 | description ?? 'display help for command', |
| 2592 | ); |
| 2593 | // init group unless lazy create |
| 2594 | if (flags || description) this._initOptionGroup(this._helpOption); |
| 2595 | |
| 2596 | return this; |
| 2597 | } |
| 2598 | |
| 2599 | /** |
| 2600 | * Lazy create help option. |
no test coverage detected