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

Method _dispatchSubcommand

lib/command.js:1364–1383  ·  view source on GitHub ↗

* @private

(commandName, operands, unknown)

Source from the content-addressed store, hash-verified

1362 */
1363
1364 _dispatchSubcommand(commandName, operands, unknown) {
1365 const subCommand = this._findCommand(commandName);
1366 if (!subCommand) this.help({ error: true });
1367
1368 subCommand._prepareForParse();
1369 let promiseChain;
1370 promiseChain = this._chainOrCallSubCommandHook(
1371 promiseChain,
1372 subCommand,
1373 'preSubcommand',
1374 );
1375 promiseChain = this._chainOrCall(promiseChain, () => {
1376 if (subCommand._executableHandler) {
1377 this._executeSubCommand(subCommand, operands.concat(unknown));
1378 } else {
1379 return subCommand._parseCommand(operands, unknown);
1380 }
1381 });
1382 return promiseChain;
1383 }
1384
1385 /**
1386 * Invoke help directly if possible, or dispatch if necessary.

Callers 2

_dispatchHelpCommandMethod · 0.95
_parseCommandMethod · 0.95

Calls 7

_findCommandMethod · 0.95
helpMethod · 0.95
_chainOrCallMethod · 0.95
_executeSubCommandMethod · 0.95
_prepareForParseMethod · 0.80
_parseCommandMethod · 0.80

Tested by

no test coverage detected