# inquirer-dynamic-list

> A subclass of inquirer's list whose choices can be updated on the fly

Latest version **1.0.0** (published 2015-10-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install inquirer-dynamic-list
pnpm add inquirer-dynamic-list
yarn add inquirer-dynamic-list
bun add inquirer-dynamic-list
```

## 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 | 2015-10-22 |
| First published | 2015-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Juan Cruz Viotti |
| Maintainers | jviotti |
| Keywords | inquirer, list, dynamic |

## Links

- npm: https://www.npmjs.com/package/inquirer-dynamic-list
- Repository: https://github.com/jviotti/inquirer-dynamic-list
- Issues: https://github.com/jviotti/inquirer-dynamic-list/issues
- npm.io page: https://npm.io/package/inquirer-dynamic-list

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^3.10.1
- [bluebird](https://npm.io/package/bluebird.md) ^2.10.2
- [inquirer](https://npm.io/package/inquirer.md) ^0.11.0

## 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

- 1.0.0 (latest) — 2015-10-22

## README

inquirer-dynamic-list
=====================

[![npm version](https://badge.fury.io/js/inquirer-dynamic-list.svg)](http://badge.fury.io/js/inquirer-dynamic-list)
[![dependencies](https://david-dm.org/jviotti/inquirer-dynamic-list.png)](https://david-dm.org/jviotti/inquirer-dynamic-list.png)
[![Build Status](https://travis-ci.org/jviotti/inquirer-dynamic-list.svg?branch=master)](https://travis-ci.org/jviotti/inquirer-dynamic-list)
[![Build status](https://ci.appveyor.com/api/projects/status/82yh8tu2vqg3mhp0?svg=true)](https://ci.appveyor.com/project/resin-io/inquirer-dynamic-list)

A subclass of inquirer's list whose choices can be updated on the fly.

Notice this is a proof of concept and breaks inquirer's encapsulation.

Installation
------------

Install `inquirer-dynamic-list` by running:

```sh
$ npm install --save inquirer-dynamic-list
```

Documentation
-------------


* [dynamiclist](#module_dynamiclist)
  * [~DynamicList](#module_dynamiclist..DynamicList)
    * [new DynamicList([options])](#new_module_dynamiclist..DynamicList_new)
    * [.render()](#module_dynamiclist..DynamicList+render)
    * [.addChoice(choice)](#module_dynamiclist..DynamicList+addChoice)
    * [.removeChoice(choice)](#module_dynamiclist..DynamicList+removeChoice)
    * [.run()](#module_dynamiclist..DynamicList+run) ⇒ <code>Promise</code>

<a name="module_dynamiclist..DynamicList"></a>
### dynamiclist~DynamicList
**Kind**: inner class of <code>[dynamiclist](#module_dynamiclist)</code>  
**Summary**: Dynamic list widget  
**Access:** public  

* [~DynamicList](#module_dynamiclist..DynamicList)
  * [new DynamicList([options])](#new_module_dynamiclist..DynamicList_new)
  * [.render()](#module_dynamiclist..DynamicList+render)
  * [.addChoice(choice)](#module_dynamiclist..DynamicList+addChoice)
  * [.removeChoice(choice)](#module_dynamiclist..DynamicList+removeChoice)
  * [.run()](#module_dynamiclist..DynamicList+run) ⇒ <code>Promise</code>

<a name="new_module_dynamiclist..DynamicList_new"></a>
#### new DynamicList([options])

| Param | Type | Default | Description |
| --- | --- | --- | --- |
| [options] | <code>Object</code> |  | options |
| options.choices | <code>Array.&lt;Object&gt;</code> |  | initial choices |
| options.message | <code>String</code> |  | widget message |
| [options.emptyMessage] | <code>String</code> | <code>&#x27;No options&#x27;</code> | message for when no choices |

**Example**  
```js
list = new DynamicList
	message: 'Foo'
	emptyMessage: 'Nothing to show'
	choices: [
		name: 'Foo'
		value: 'foo'
	]

# Run the list widget
list.run().then (answer) ->
	console.log(answer)

# You can add new choices on the fly
list.addChoice
	name: 'Bar'
	value: 'bar'

# We re-render to be able to see the new options
list.render()
```
<a name="module_dynamiclist..DynamicList+render"></a>
#### dynamicList.render()
**Kind**: instance method of <code>[DynamicList](#module_dynamiclist..DynamicList)</code>  
**Summary**: Render the list  
**Access:** public  
**Example**  
```js
list = new DynamicList
	message: 'Foo'
	emptyMessage: 'Nothing to show'
	choices: [
		name: 'Foo'
		value: 'foo'
	]

list.render()
```
<a name="module_dynamiclist..DynamicList+addChoice"></a>
#### dynamicList.addChoice(choice)
**Kind**: instance method of <code>[DynamicList](#module_dynamiclist..DynamicList)</code>  
**Summary**: Add a choice  
**Access:** public  

| Param | Type | Description |
| --- | --- | --- |
| choice | <code>Object</code> | choice |

**Example**  
```js
list = new DynamicList
	message: 'Foo'
	emptyMessage: 'Nothing to show'
	choices: [
		name: 'Foo'
		value: 'foo'
	]

list.addChoice(name: 'Bar', value: 'bar')
list.render()
```
<a name="module_dynamiclist..DynamicList+removeChoice"></a>
#### dynamicList.removeChoice(choice)
**Kind**: instance method of <code>[DynamicList](#module_dynamiclist..DynamicList)</code>  
**Summary**: Remove a choice  
**Access:** public  

| Param | Type | Description |
| --- | --- | --- |
| choice | <code>Object</code> | choice |

**Example**  
```js
list = new DynamicList
	message: 'Foo'
	emptyMessage: 'Nothing to show'
	choices: [
		name: 'Foo'
		value: 'foo'
	]

list.removeChoice(name: 'Foo', value: 'foo')
list.render()
```
<a name="module_dynamiclist..DynamicList+run"></a>
#### dynamicList.run() ⇒ <code>Promise</code>
**Kind**: instance method of <code>[DynamicList](#module_dynamiclist..DynamicList)</code>  
**Summary**: Run the widget  
**Access:** public  
**Fulfil**: <code>String</code> answer  
**Example**  
```js
list = new DynamicList
	message: 'Foo'
	emptyMessage: 'Nothing to show'
	choices: [
		name: 'Foo'
		value: 'foo'
	]

list.run().then (answer) ->
	console.log(answer)
```

Support
-------

If you're having any problem, please [raise an issue](https://github.com/jviotti/inquirer-dynamic-list/issues/new) on GitHub and I'll be happy to help.

Tests
-----

Run the test suite by doing:

```sh
$ gulp test
```

Contribute
----------

- Issue Tracker: [github.com/jviotti/inquirer-dynamic-list/issues](https://github.com/jviotti/inquirer-dynamic-list/issues)
- Source Code: [github.com/jviotti/inquirer-dynamic-list](https://github.com/jviotti/inquirer-dynamic-list)

Before submitting a PR, try to include tests, and make sure that [coffeelint](http://www.coffeelint.org/) runs without any warning:

```sh
$ gulp lint
```

License
-------

The project is licensed under the MIT license.

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