# @joegesualdo/prompt-node

> Command line prompt.

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

## Install

```sh
npm install @joegesualdo/prompt-node
pnpm add @joegesualdo/prompt-node
yarn add @joegesualdo/prompt-node
bun add @joegesualdo/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-10 |
| First published | 2016-07-09 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | joegesualdo |
| Keywords | prompt, cli, command, line |

## Links

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

## Dependencies (2)

- [chalk](https://npm.io/package/chalk.md) ^1.1.3
- [string-length](https://npm.io/package/string-length.md) ^1.0.1

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

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

## README

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

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

## Highlights

- Supports validation
- Hides password

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

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

new Prompt('Are you tired?')
.on('done', answer => {
  console.log(`You've answered '${answer}'`)
})
.begin()
```

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

#### Params
| Name |   Type  | Default |   Description    |
|------|---------|---------|------------------|
| text | `Array` |   ` `   | Test description |

#### Options
| Name       | Type       | Default              | Description                   |
|------------|------------|----------------------|-------------------------------|
| hidden     | `Boolean`  | `false`              | Should answer be hidden?      |
| required   | `Boolean`  | `false`              | Does it accept empty answers? |
| validation | `Function` | `() => {return true}`| Test if answer is valid       |

Returns: `prompt`

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

new Prompt('Are you tired?', {
  required: true,
  hidden: true,
  validation: (answer) => {
    return answer === 'woo';
  }
})
```

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

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

new Prompt('Are you tired?')
.on('done', answer => {
  console.log(`You've answered '${answer}'`)
})
.begin()
```

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

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

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

new Prompt('Are you tired?')
.on('validationError', answer => {
})
.on('backspace', () => {
})
.on('change', (oldStr, newStr ) => {
})
.on('done', answer => {
  console.log(`You've answered '${answer}'`)
})
.begin()
```

## Build
```
$ npm run build
```

## License
MIT © [Joe Gesualdo]()

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