Skip to content

Commit

Permalink
feat: Add getter isSkipable to CommandArgument class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayfri committed Aug 31, 2021
1 parent c66ce3e commit 35f118a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/classes/arguments/Argument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,8 @@ export class CommandArgument<T> {
public get isSimple() {
return !this.optional && !this.coalescing && !this.defaultValue;
}

public get isSkipable(): boolean {
return this.optional || !!this.defaultValue;
}
}
2 changes: 1 addition & 1 deletion src/classes/arguments/ArgumentParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class ArgumentParser {
i++;
}

const argsRequiredCount = this.args.filter(a => a.isSimple);
const argsRequiredCount = this.args.filter(a => !a.isSkipable);
if (argsMap.size < argsRequiredCount.length) {
for (let i = argsMap.size; i < argsRequiredCount.length; i++) {
const currentArgument = argsRequiredCount[i];
Expand Down

0 comments on commit 35f118a

Please sign in to comment.