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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: describe yargs.async API surface #1491

Closed
wants to merge 3 commits into from
Closed
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
41 changes: 41 additions & 0 deletions docs/async.md
@@ -0,0 +1,41 @@
# Async API

_Note: this document describes an API that has not yet been implemented, and
serves as a design document._

yargs exposes an async API surface, making it easier to compose command driven
applications that perform asynchronous operations.

As an example, perhaps you would like to create a command line application that
fetches the contents of a URL:

```js
const fetch = require('node-fetch')
const yargs = require('yargs').async
const argv = yargs.command('fetch <url>', 'fetch the contents of a URL', () => {}, async (argv) => {
const res = await fetch(argv.url)
console.info(`status = ${res.status} ${res.statusText}`)
console.info(await res.text())
}).argv
await argv // resolves when the command has finished.
```

Detailed specifics of the `yargs.async` API follow:

## `yargs.async`

To create an asynchronous application simply use the `require('yargs').async`
statement, rather than `require('yargs')`.

The asynchronous API surface varies from the synchronous API surface in a
variety of ways...

## `.argv`

## `.parse`

## Command Builders

## Command Handlers

## Middleware