From 6ca7bb2a719f792487f4e2104d6377ccf1e423dd Mon Sep 17 00:00:00 2001 From: n loewen Date: Tue, 29 Aug 2023 22:22:41 -0400 Subject: [PATCH] Change some undefined variables --- arg-parser.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arg-parser.js b/arg-parser.js index b1ce932..99bf0cc 100755 --- a/arg-parser.js +++ b/arg-parser.js @@ -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 + }); } }