Change some undefined variables
This commit is contained in:
parent
584d9dd95f
commit
6ca7bb2a71
|
|
@ -19,11 +19,10 @@ function Arg({
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
function Arguments(argumentsObject=[], helpText='') {
|
function Arguments(argumentsObject=[]) {
|
||||||
this.help = helpText;
|
|
||||||
this.args = argumentsObject;
|
this.args = argumentsObject;
|
||||||
|
|
||||||
Arguments.prototype.add = (...a) => a.forEach((x) => argumentsObject.push(new Arg(x)));
|
this.add = (...a) => a.forEach((x) => argumentsObject.push(new Arg(x)));
|
||||||
|
|
||||||
this.parse = function() {
|
this.parse = function() {
|
||||||
const argsRequiringValues = this.args.filter((a) => a.requiresValue);
|
const argsRequiringValues = this.args.filter((a) => a.requiresValue);
|
||||||
|
|
@ -55,9 +54,11 @@ function Arguments(argumentsObject=[], helpText='') {
|
||||||
// Check for attempts to use --flags that don't exist
|
// Check for attempts to use --flags that don't exist
|
||||||
let valid = true;
|
let valid = true;
|
||||||
if (av.startsWith('--')) {
|
if (av.startsWith('--')) {
|
||||||
valid = cpuArguments.args.filter((a) => a.flags.long === av.substring(2)).length > 0;
|
// TODO: this may be wrong:
|
||||||
|
valid = this.args.filter((a) => a.flags.long === av.substring(2)).length > 0;
|
||||||
} else if (av.startsWith('-')) {
|
} else if (av.startsWith('-')) {
|
||||||
valid = cpuArguments.args.filter((a) => a.flags.short === av.substring(1)).length > 0;
|
// TODO: this may be wrong:
|
||||||
|
valid = this.args.filter((a) => a.flags.short === av.substring(1)).length > 0;
|
||||||
}
|
}
|
||||||
if (!valid) { throw new Error(`There is no ${av} option`); }
|
if (!valid) { throw new Error(`There is no ${av} option`); }
|
||||||
|
|
||||||
|
|
@ -77,6 +78,7 @@ function Arguments(argumentsObject=[], helpText='') {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO return something useful
|
// TODO return something useful
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue