diff --git a/src/lib/commandDispatcher.js b/src/lib/commandDispatcher.js index c32a0e3..9681dfa 100644 --- a/src/lib/commandDispatcher.js +++ b/src/lib/commandDispatcher.js @@ -21,11 +21,11 @@ function removeStartHyphens(val) { // taken from ethanent/gar // modified to make - arguments only be bools unless = -function parseAsArgv(argv) { +function parseAsArgv(args) { const optional = {}; - const args = []; - for (const arg of argv) { + for (let i = 0; i < args.length; i++) { + const arg = args.shift(); const equalsIndex = arg.charAt(0) === "-" ? arg.indexOf("=") : -1; const argName = equalsIndex === -1 @@ -43,7 +43,9 @@ function parseAsArgv(argv) { } } } else { - args.push(convertIfApplicable(argName)); + // all optional args must be at the start of the argument string + args.splice(0, 0, arg); + break; } }