commandDispatcher: argv only parsed if front of arguments
This commit is contained in:
parent
2851dbed24
commit
a9c293e8fb
1 changed files with 6 additions and 4 deletions
|
@ -21,11 +21,11 @@ function removeStartHyphens(val) {
|
||||||
|
|
||||||
// taken from ethanent/gar
|
// taken from ethanent/gar
|
||||||
// modified to make - arguments only be bools unless =
|
// modified to make - arguments only be bools unless =
|
||||||
function parseAsArgv(argv) {
|
function parseAsArgv(args) {
|
||||||
const optional = {};
|
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 equalsIndex = arg.charAt(0) === "-" ? arg.indexOf("=") : -1;
|
||||||
const argName =
|
const argName =
|
||||||
equalsIndex === -1
|
equalsIndex === -1
|
||||||
|
@ -43,7 +43,9 @@ function parseAsArgv(argv) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
args.push(convertIfApplicable(argName));
|
// all optional args must be at the start of the argument string
|
||||||
|
args.splice(0, 0, arg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue