# unquirer

> Wrapper for inquirer to allow arguments to override answers

Latest version **1.0.0** (published 2018-05-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install unquirer
pnpm add unquirer
yarn add unquirer
bun add unquirer
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2018-05-14 |
| First published | 2018-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Antony Jones |
| Maintainers | antony |

## Links

- npm: https://www.npmjs.com/package/unquirer
- npm.io page: https://npm.io/package/unquirer

## Dependencies (1)

- [args-parser](https://npm.io/package/args-parser.md) ^1.1.0

## Recent versions

- 1.0.0 (latest) — 2018-05-14

## README

## Unquirer

A wrapper for [Inquirer](https://www.npmjs.com/package/inquirer) to allow pre-answering questions with command line arguments

### Installation

This library has a peer dependency of inquirer, so make sure you also install it.

```bash
  npm install --save unquirer inquirer
```

### Usage

Given the following highly opinionated version of the inquirer 'input' example, to demonstrate `filter` and `validate` support:

```javascript
  const unquirer = require('unquirer')

  var questions = [
    {
      type: 'input',
      name: 'firstName',
      message: "What's your first name"
    },
    {
      type: 'input',
      name: 'lastName',
      message: 'What's your last name',
      filter: answer => {
        return 'Smith'
      }
    },
    {
      type: 'input',
      name: 'favColor',
      message: "What's your favorite color",
      validate: answer => {
        if (answer === 'yellow') { return true }
        return "You can only like yellow!"
      }
    }
  ]

  async function go () {
    const answers = await unquirer.prompt(questions)
    console.log(JSON.stringify(answers, null, '  '))
  }

  go()
```

You could call this program in the regular way, to be prompted for all the questions:

```bash
  node input.js
```

Or, you could pass some of the answers in, and only be prompted about favColor:

```bash
  node input.js --firstName="Jim" --lastName="Smith"
```

Or you can pass in all the answers, totally non-interactive:

```bash
  node input.js --firstName="Jim" --lastName="Smith" --favColor="yellow"
```

### Options

Options are passed as the second parameter to the `unquirer.prompt` method.

There is currently only one option, `useCamelCase`, which defaults to true. This pption causes parameters like `--some-param` to result in the answer key `someParam`. In order to preserve dashes in your `question` `name`s, pass `{ useCamelCase: false }` as options.

### Validation

Validation works the same as it does in Inquirer, i.e. in your validation method, return `true` to pass validation, return `false` to fail with a default message, and return any `string` to fail with that specific message.

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