Skip to content
Myr

Have help command call help directly for subcommands, when possible (#1864)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by John Gee · committed by GitHub · parent fac9d8c · Browse files · 2 files+58 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+58 added−4 removed

  • tests:+37 added−0 removed
  • other:+21 added−4 removed

2 files+58 added−4 removed

modified:lib/command.js+21 added-4 removed
1083 unmodified lines
1084 return hookResult;1085 }10861087 /**1088 * Invoke help directly if possible, or dispatch if necessary.1089 * e.g. help foo1090 *1091 * @api private1092 */10931094 _dispatchHelpCommand(subcommandName) {1095 if (!subcommandName) {1096 this.help();1097 }1098 const subCommand = this._findCommand(subcommandName);1099 if (subCommand && !subCommand._executableHandler) {1100 subCommand.help();1101 }11021103 // Fallback to parsing the help flag to invoke the help.1104 return this._dispatchSubcommand(subcommandName, [], [this._helpLongFlag]);1105 }11061107 /**1108 * Check this.args against expected this._args.1109 *1110 * @api private1111 */
155 unmodified lines
1267 if (operands && this._findCommand(operands[0])) {1268 return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);1269 }1270 if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {1251 if (operands.length === 1) {1252 this.help();1253 }1254 return this._dispatchSubcommand(operands[1], [], [this._helpLongFlag]);1271 return this._dispatchHelpCommand(operands[1]);1272 }1273 if (this._defaultCommandName) {1274 outputHelpIfRequested(this, unknown); // Run the help for default command from parent rather than passing to default command1275 return this._dispatchSubcommand(this._defaultCommandName, operands, unknown);
921 unmodified lines
modified:tests/command.helpCommand.test.js+37 added