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

feat: adds support for async builder #1888

Merged
merged 7 commits into from Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/advanced.md
Expand Up @@ -557,7 +557,7 @@ var argv = require('yargs/yargs')(process.argv.slice(2))

## Using Yargs with Async/await

If you use async middleware or async handlers for commands, `yargs.parse` and
If you use async middleware or async builders/handlers for commands, `yargs.parse` and
`yargs.argv` will return a `Promise`. When you `await` this promise the
parsed arguments object will be returned after the handler completes:

Expand Down
7 changes: 5 additions & 2 deletions docs/api.md
Expand Up @@ -293,11 +293,14 @@ yargs
```

`builder` can also be a function. This function is executed
with a `yargs` instance, and can be used to provide _advanced_ command specific help:
with a `yargs` instance, which can be used to provide command specific
configuration, and the boolean `helpOrVersionSet`, which indicates whether or
not the `--help` or `--version` flag was set prior to calling the
builder.

```js
yargs
.command('get', 'make a get HTTP request', function (yargs) {
.command('get', 'make a get HTTP request', function (yargs, helpOrVersionSet) {
return yargs.option('url', {
alias: 'u',
default: 'http://yargs.js.org/'
Expand Down