Change some undefined variables

This commit is contained in:
n loewen 2023-08-29 22:22:41 -04:00
parent 584d9dd95f
commit 6ca7bb2a71
1 changed files with 7 additions and 5 deletions

View File

@ -19,11 +19,10 @@ function Arg({
};
function Arguments(argumentsObject=[], helpText='') {
this.help = helpText;
function Arguments(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() {
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
let valid = true;
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('-')) {
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`); }
@ -77,6 +78,7 @@ function Arguments(argumentsObject=[], helpText='') {
}
// TODO return something useful
});
}
}