Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,12 @@ Now, by simply wrapping your CLI code with this tool, you'll get all the informa

It supports the following use cases

- [Prompt all questions](#prompt-questions-with-default-values-full-interactive)
- [Prompt some questions (mixed mode)](#prompt-just-some-questions-mixed-mode)
- [Prompt all questions (full-interactive)](#prompt-all-questions-full-interactive)
- [Prompt some questions (mixed mode)](#prompt-some-questions-mixed-mode)
- [No prompt at all (ye olde yargs)](#no-prompt-at-all-ye-olde-yargs)
- [Nested interactive questions](#nested-interactive-questions)

### Prompt questions (full-interactive)
### Prompt all questions (full-interactive)

**my-cli.js**

Expand Down Expand Up @@ -207,3 +208,41 @@ yargsInteractive()
```
➜ node my-cli.js --name='Johh' --likesPizza
```

### Nested Interactive Questions

```js
/* my-cli.js */
const globalOptions = {
name: {
type: 'input',
default: 'nano',
describe: 'Enter your name',
},
};

yargsInteractive()
.usage("$0 <command> [args]")
.interactiveOptions(globalOptions)
.commandDir('./commands');
```

```js
/* ./commands/command.js */
const options = {
likesPizza: {
type: 'confirm',
default: false,
describe: 'Do you like pizza?',
},
};

module.exports = {
command = 'order',
description = 'Order some food',
builder: (yargs) => yargs
.interactive(options)
.then(opts => {
// ...
});
```
Loading