Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Command.awaitHook(), Argument.chainArgParserCalls() and Option.chainArgParserCalls() #1902

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
4061bff
Add Command.awaitHook() (#1900)
aweebit Jul 6, 2023
4a6e07c
Add support for variadic thenable chains (#1902)
aweebit Jul 6, 2023
4738e3c
Improve error handling and performance (#1902)
aweebit Jul 6, 2023
c0b7e74
Properly handle parseArg rejections (#1902)
aweebit Jul 7, 2023
200b31d
Improve rejection handling (#1902)
aweebit Jul 7, 2023
2114a72
Make parseArg() call chaining optional (#1902)
aweebit Jul 7, 2023
7d1038e
Only await chained arguments and options (#1902)
aweebit Jul 7, 2023
dbca267
Improve option lookup performance (#1902)
aweebit Jul 7, 2023
6f795f7
Fix asynchronous custom processing logic (#1902)
aweebit Jul 7, 2023
e632f84
Add chainArgParserCalls() tests (#1902)
aweebit Jul 7, 2023
b96474c
Add tests for repeated options (#1902)
aweebit Jul 7, 2023
6c44e2b
Improve thenable handling and use in tests (#1902)
aweebit Jul 8, 2023
ca48392
Get rid of linting errors
aweebit Jul 8, 2023
287cdc7
Add global option support for awaitHook() (#1902)
aweebit Jul 23, 2023
1830e14
Get rid of dangling promises (#1902)
aweebit Jul 23, 2023
a451ac5
parseAsync() with awaitHook() by default & postArguments hooks (#1902)
aweebit Jul 23, 2023
3a956b5
Make await hooks last by default (#1902)
aweebit Jul 23, 2023
96b9fc2
Add type tests (#1902)
aweebit Jul 23, 2023
62700a3
Avoid promise chaining when possible (#1902)
aweebit Jul 24, 2023
9a2a2b5
Add thenable function & name method better (#1902)
aweebit Jul 25, 2023
51d460c
Fix bug
aweebit Jul 25, 2023
94cb5ab
Recover old tests that now pass
aweebit Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/argument.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Argument {
this.description = description || '';
this.variadic = false;
this.parseArg = undefined;
this.chained = false;
this.defaultValue = undefined;
this.defaultValueDescription = undefined;
this.argChoices = undefined;
Expand Down Expand Up @@ -89,6 +90,17 @@ class Argument {
return this;
}

/**
* When set to true, next call to the function provided via .argParser() will be chained to its return value if it is thenable.
*
* @param {boolean} [chained]
* @return {Argument}
*/
chainArgParserCalls(chained = true) {
this.chained = !!chained;
return this;
}

/**
* Only allow argument value to be one of choices.
*
Expand Down