# cli-interact

> Simple helper tools for interacting synchronously with user at command line

Latest version **0.1.9** (published 2015-01-08) · 0 weekly downloads

## Install

```sh
npm install cli-interact
pnpm add cli-interact
yarn add cli-interact
bun add cli-interact
```

## Health

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

Positive: has types package; no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2015-01-08 |
| First published | 2014-11-14 |
| Weekly downloads | 0 |
| TypeScript types | separate (@types/cli-interact) |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Stuart Malin |
| Maintainers | zhami |
| Keywords | readline, synchronous, prompt, question, wait, block |

## Links

- npm: https://www.npmjs.com/package/cli-interact
- Repository: https://github.com/zhami/cli-interact
- Issues: https://github.com/zhami/cli-interact/issues
- npm.io page: https://npm.io/package/cli-interact

## Dependencies (1)

- [readline-sync](https://npm.io/package/readline-sync.md) ~0.4.9

## 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.1.9 (latest) — 2015-01-08
- 0.1.8 — 2014-12-29
- 0.1.7 — 2014-12-29
- 0.1.6 — 2014-11-24
- 0.1.5 — 2014-11-21
- 0.1.4 — 2014-11-20
- 0.1.3 — 2014-11-20
- 0.1.2 — 2014-11-20
- 0.1.1 — 2014-11-14
- 0.1.0 — 2014-11-14

## README

# cli-interact

Simple helper tools for interacting synchronously with user at command line. The interface is used with `process.stdin` and `process.stdout` in order to accept user input.

## Example

```js
var	query = require('cli-interact').getYesNo;
var answer = query('Is it true');
console.log('you answered:', answer);
```

```
$ node examples/getYesNoNone.js
Is it true (y/n)? j
Is it true (y/n)? y
you answered: true
```

## Installation

```
npm install cli-interact
```

## Usage

## Queries

Presently, there are three queries:

`getChar` gets a single character from some set of allowed characters.

`getIPversion` gets a single character, either '4' or '6'.

`getYesNo` prompts for 'y' or 'n', returns true/false. Can be configured to allow no response (returns `undefined`).

And a passthorugh `question` to access the underlying `readlineSync.question` method.

## Notes
Uses the [readline-sync](https://github.com/anseki/readline-sync) module. See it for more information.

### Platforms

The your Node and OS may not support interactively reading from stdin. The stdin interfaces are different by platforms. If in those platforms, an error is thrown by readlineSync.

```js
try {
  answer = readlineSync.question('What is your favorite food? :');
} catch (e) {
  console.error(e);
  process.exit(1);
}
```

## Release History
  * 2014-11-14			v0.1.0			Initial release.

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