Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
fix(ArgumentParser): optional bs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexthemaster committed Jul 31, 2020
1 parent 6078420 commit 55228b9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib/util/ArgumentParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export class ArgumentParser {
for (const arg in parsedArgs) {
const argumentObject = parsedArgs[arg];

// If there isn't any more text to process and the argument is optional then return, else throw a message
if (!this.text.length && argumentObject.type === 'optional') return;
else if (!this.text.length) throw { arg, message: `${arg} is a required argument!` };

let toParse: string | undefined;

if (argumentObject.processEverything) {
Expand All @@ -49,6 +45,8 @@ export class ArgumentParser {
toParse = temp;
} else toParse = this.text[0];

// If there isn't anything to parse and the argument is optional then continue, else throw a message
if (!toParse.length && argumentObject.type === 'optional') continue;
if (!toParse.length) throw { arg, message: `${arg} is a required argument!` };

// If there isn't an argument type specified then we check for a direct string match, and if the argument is not optional also throw a message
Expand Down

0 comments on commit 55228b9

Please sign in to comment.