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 + }); } }