* @typedef HelpContext * @type {object} * @property {boolean} error * @property {number} helpWidth * @property {boolean} hasColors * @property {function} write - includes stripColor if needed * * @returns {HelpContext} * @private
(contextOptions)
| 2487 | */ |
| 2488 | |
| 2489 | _getOutputContext(contextOptions) { |
| 2490 | contextOptions = contextOptions || {}; |
| 2491 | const error = !!contextOptions.error; |
| 2492 | let baseWrite; |
| 2493 | let hasColors; |
| 2494 | let helpWidth; |
| 2495 | if (error) { |
| 2496 | baseWrite = (str) => this._outputConfiguration.writeErr(str); |
| 2497 | hasColors = this._outputConfiguration.getErrHasColors(); |
| 2498 | helpWidth = this._outputConfiguration.getErrHelpWidth(); |
| 2499 | } else { |
| 2500 | baseWrite = (str) => this._outputConfiguration.writeOut(str); |
| 2501 | hasColors = this._outputConfiguration.getOutHasColors(); |
| 2502 | helpWidth = this._outputConfiguration.getOutHelpWidth(); |
| 2503 | } |
| 2504 | const write = (str) => { |
| 2505 | if (!hasColors) str = this._outputConfiguration.stripColor(str); |
| 2506 | return baseWrite(str); |
| 2507 | }; |
| 2508 | return { error, write, hasColors, helpWidth }; |
| 2509 | } |
| 2510 | |
| 2511 | /** |
| 2512 | * Output help information for this command. |
no test coverage detected