From d65dabd96b78bbefe700ddca24d88b07ff7133d0 Mon Sep 17 00:00:00 2001 From: Carl Orthlieb Date: Fri, 3 Aug 2012 12:52:09 -0700 Subject: [PATCH] Fix issue #56 Leftover arguments need to be pushed back onto the args stack. Makes sure that options don't strip of arguments they shouldn't --- lib/commander.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/commander.js b/lib/commander.js index b665194b0..fb656c3a4 100644 --- a/lib/commander.js +++ b/lib/commander.js @@ -213,6 +213,12 @@ Command.prototype.action = function(fn){ self.unknownOption(parsed.unknown[0]); } + // Leftover arguments need to be pushed back onto the args stack + // Fixes issue #56 + if (parsed.args.length > 0) { + args = parsed.args.concat(args); + } + self.args.forEach(function(arg, i){ if (arg.required && null == args[i]) { self.missingArgument(arg.name);