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

Method argumentDescription

lib/help.js:373–394  ·  view source on GitHub ↗

* Get the argument description to show in the list of arguments. * * @param {Argument} argument * @return {string}

(argument)

Source from the content-addressed store, hash-verified

371 */
372
373 argumentDescription(argument) {
374 const extraInfo = [];
375 if (argument.argChoices) {
376 extraInfo.push(
377 // use stringify to match the display of the default value
378 `choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
379 );
380 }
381 if (argument.defaultValue !== undefined) {
382 extraInfo.push(
383 `default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,
384 );
385 }
386 if (extraInfo.length > 0) {
387 const extraDescription = `(${extraInfo.join(', ')})`;
388 if (argument.description) {
389 return `${argument.description} ${extraDescription}`;
390 }
391 return extraDescription;
392 }
393 return argument.description;
394 }
395
396 /**
397 * Format a list of items, given a heading and an array of formatted items.

Callers 3

formatHelpMethod · 0.80
index.test-d.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected