MCPcopy
hub / github.com/tj/commander.js / _getOutputContext

Method _getOutputContext

lib/command.js:2489–2509  ·  view source on GitHub ↗

* @typedef HelpContext * @type {object} * @property {boolean} error * @property {number} helpWidth * @property {boolean} hasColors * @property {function} write - includes stripColor if needed * * @returns {HelpContext} * @private

(contextOptions)

Source from the content-addressed store, hash-verified

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.

Callers 2

helpInformationMethod · 0.95
outputHelpMethod · 0.95

Calls 6

writeErrMethod · 0.80
getErrHasColorsMethod · 0.80
getErrHelpWidthMethod · 0.80
writeOutMethod · 0.80
getOutHasColorsMethod · 0.80
getOutHelpWidthMethod · 0.80

Tested by

no test coverage detected