Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
add (static) default value support for types
Browse files Browse the repository at this point in the history
  • Loading branch information
WRMSRwasTaken committed Sep 21, 2018
1 parent e59cda3 commit cd5d38b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/commandHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,11 @@ class CommandHandler {
parsedArguments.push(currentArgument.default);
}
} else if (argumentParser.default) {
parsedArguments.push(await argumentParser.default(context));
if (typeof argumentParser.default === 'function') {
parsedArguments.push(await argumentParser.default(context));
} else {
parsedArguments.push(argumentParser.default);
}
} else {
parsedArguments.push(undefined);
}
Expand Down
2 changes: 1 addition & 1 deletion types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ This folder contains the files for each type the argument parser will validate t
* `value` the input word as string (or a multi-word string if entered by the user)
* `argument` argument options that have been set in the respective command file
* `context` the context object, see the [context documentation](../context.md)
- `default()` the function that will be executed if `optional` has been set to true in the command file, passed arguments:
- `default()` a value or a function that will be executed if `optional` has been set to true in the command file, passed arguments:
* `context` the context object, see `context.md`

0 comments on commit cd5d38b

Please sign in to comment.