# @joegesualdo/multi-prompt-node

> Multiple command line prompts.

Latest version **0.0.5** (published 2016-07-11) · 0 weekly downloads

## Install

```sh
npm install @joegesualdo/multi-prompt-node
pnpm add @joegesualdo/multi-prompt-node
yarn add @joegesualdo/multi-prompt-node
bun add @joegesualdo/multi-prompt-node
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2016-07-11 |
| First published | 2016-07-11 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | joegesualdo |
| Keywords | multi, prompt, command, line, terminal |

## Links

- npm: https://www.npmjs.com/package/@joegesualdo/multi-prompt-node
- Repository: https://github.com/joegesualdo/multi-prompt-node
- Homepage: https://github.com/joegesualdo/multi-prompt-node#readme
- Issues: https://github.com/joegesualdo/multi-prompt-node/issues
- npm.io page: https://npm.io/package/@joegesualdo/multi-prompt-node

## Dependencies (6)

- [chalk](https://npm.io/package/chalk.md) ^1.1.3
- [strip-ansi](https://npm.io/package/strip-ansi.md) ^3.0.1
- [string-length](https://npm.io/package/string-length.md) ^1.0.1
- [@joegesualdo/prompt-node](https://npm.io/package/@joegesualdo/prompt-node.md) 0.0.5
- [@joegesualdo/indent-string](https://npm.io/package/@joegesualdo/indent-string.md) 0.0.5
- [@joegesualdo/promise-queue](https://npm.io/package/@joegesualdo/promise-queue.md) 0.0.5

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 0.0.5 (latest) — 2016-07-11
- 0.0.4 — 2016-07-11
- 0.0.3 — 2016-07-11
- 0.0.2 — 2016-07-11
- 0.0.1 — 2016-07-11

## README

## multi-prompt [![Build Status](https://travis-ci.org/joegesualdo/multi-prompt-node.svg?branch=master)](https://travis-ci.org/joegesualdo/multi-prompt-node)
> Multiple command line prompts.

## Install
```
$ npm install --save @joegesualdo/multi-prompt-node
```

![demo](https://github.com/joegesualdo/multi-prompt-node/raw/master/demo.gif)

## Usage
```javascript
import MultiPrompt from '@joegesualdo/multi-prompt-node';

const questions = [
  {
    prompt: `What's your name?`,
  },
  {
    prompt: `How old are you?`,
  },
]

new MultiPrompt(questions)
.on('done', result => {
  console.log(result)
})
.begin()
```

## Test
```
$ npm test
```
## API
### `MultiPrompt(prompts, [options])`
> Instantiates a new prompt

#### Params
| Name |   Type  | Default |   Description    |
|------|---------|---------|------------------|
| prompts | `Array<Object>` |   `[]`   | An object representing properties of a prompt |
| options | `Object` |   `{}`   | Configuration options |

#### Example Promp Object:
```
{
  identifier: 'who',
  prompt: ` Where do you live?`,
  dependent: {
    question: 'language',
    answers: [
      'ruby'
    ]
  },
  validation: (answer) => {
    return ['node', 'ruby'].indexOf(answer) !== -1;
  }
  onDone: (answer) => {
    return 'I am no one :-)'
  }
}
```
#### Options
| Name |   Type  | Default |   Description    |
|------|---------|---------|------------------|
| indent | `Number` |   `2`   | How many spaces do you want the prompts to be indented |

Returns: `multiPrompt`

### `multiPrompt.begin()`
> Starts the prompt

```javascript
import MultiPrompt from '@joegesualdo/multi-prompt-node'

const questions = [
  {
    prompt: `What's your name?`,
  },
  {
    prompt: `How old are you?`,
  },
]

new MultiPrompt(questions, {
  indent: 4,
})
.on('done', result=> {
  console.log(result)
})
.begin()
```

### `multiPrompt.on(type, fn)`
> Sets lifecycle methods

#### Params
| Name |   Type     | Default |   Description      | Possible values |
|------|------------|---------|--------------------|-----------------|
| type | `String`   |  `N/A`  | The lifecycle name | `done` |
| fn   | `Function` |  `N/A`  | Function to run    | `N/A`|

```javascript
import MultiPrompt from '@joegesualdo/multi-prompt-node'

const questions = [
  {
    prompt: `What's your name?`,
  },
  {
    prompt: `How old are you?`,
  },
]

new MultiPrompt(questions)
.on('done', result=> {
  console.log(result)
})
.begin()
```
## Build
```
$ npm run build
```

## Related
- [prompt-node](https://github.com/joegesualdo/prompt-node) - Command line prompt

## License
MIT © [Joe Gesualdo]()

---
_Source: https://npm.io/package/@joegesualdo/multi-prompt-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
