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

Method commandUsage

lib/help.js:277–292  ·  view source on GitHub ↗

* Get the command usage to be displayed at the top of the built-in help. * * @param {Command} cmd * @returns {string}

(cmd)

Source from the content-addressed store, hash-verified

275 */
276
277 commandUsage(cmd) {
278 // Usage
279 let cmdName = cmd._name;
280 if (cmd._aliases[0]) {
281 cmdName = cmdName + '|' + cmd._aliases[0];
282 }
283 let ancestorCmdNames = '';
284 for (
285 let ancestorCmd = cmd.parent;
286 ancestorCmd;
287 ancestorCmd = ancestorCmd.parent
288 ) {
289 ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;
290 }
291 return ancestorCmdNames + cmdName + ' ' + cmd.usage();
292 }
293
294 /**
295 * Get the description for the command.

Callers 4

formatHelpMethod · 0.80
help.style.test.jsFile · 0.80
index.test-d.tsFile · 0.80

Calls 2

usageMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected