Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore arguments order to pass to subcommands #734

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,16 @@ Command.prototype.parse = function(argv) {
}

if (this._execs[name] && typeof this._execs[name] !== 'function') {
return this.executeSubCommand(argv, args, parsed.unknown);
this.args = args = argv.slice(2)
return this.executeSubCommand(argv, args);
} else if (aliasCommand) {
// is alias of a subCommand
args[0] = aliasCommand._name;
return this.executeSubCommand(argv, args, parsed.unknown);
this.args = args = [ aliasCommand._name ].concat(argv.slice(3))
return this.executeSubCommand(argv, args);
} else if (this.defaultExecutable) {
// use the default subcommand
args.unshift(this.defaultExecutable);
return this.executeSubCommand(argv, args, parsed.unknown);
this.args = args = [ this.defaultExecutable ].concat(argv.slice(3))
return this.executeSubCommand(argv, args);
}

return result;
Expand All @@ -508,9 +509,7 @@ Command.prototype.parse = function(argv) {
* @api private
*/

Command.prototype.executeSubCommand = function(argv, args, unknown) {
args = args.concat(unknown);

Command.prototype.executeSubCommand = function(argv, args) {
if (!args.length) this.help();
if (args[0] === 'help' && args.length === 1) this.help();

Expand Down