Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: adds support for async builder (#1888)
Fixes: #1042
BREAKING CHANGE: providing an async builder will now cause yargs to return async result
BREAKING CHANGE: .positional() now allowed at root level of yargs.
  • Loading branch information
bcoe committed Mar 26, 2021
1 parent b96ef01 commit ade29b8
Show file tree
Hide file tree
Showing 10 changed files with 613 additions and 409 deletions.
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

0 comments on commit ade29b8

Please sign in to comment.