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

Method unknownCommand

lib/command.js:2176–2194  ·  view source on GitHub ↗

* Unknown command. * * @private

()

Source from the content-addressed store, hash-verified

2174 */
2175
2176 unknownCommand() {
2177 const unknownName = this.args[0];
2178 let suggestion = '';
2179
2180 if (this._showSuggestionAfterError) {
2181 const candidateNames = [];
2182 this.createHelp()
2183 .visibleCommands(this)
2184 .forEach((command) => {
2185 candidateNames.push(command.name());
2186 // just visible alias
2187 if (command.alias()) candidateNames.push(command.alias());
2188 });
2189 suggestion = suggestSimilar(unknownName, candidateNames);
2190 }
2191
2192 const message = `error: unknown command '${unknownName}'${suggestion}`;
2193 this.error(message, { code: 'commander.unknownCommand' });
2194 }
2195
2196 /**
2197 * Get or set the program version.

Callers 1

_parseCommandMethod · 0.95

Calls 6

createHelpMethod · 0.95
errorMethod · 0.95
suggestSimilarFunction · 0.90
visibleCommandsMethod · 0.80
aliasMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected