Package Exports
- inquirer-dynamic-list
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (inquirer-dynamic-list) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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:
$ npm install --save inquirer-dynamic-list
Documentation
dynamiclist~DynamicList
Kind: inner class of dynamiclist
Summary: Dynamic list widget
Access: public
new DynamicList([options])
Param | Type | Default | Description |
---|---|---|---|
[options] | Object |
options | |
options.choices | Array.<Object> |
initial choices | |
options.message | String |
widget message | |
[options.emptyMessage] | String |
'No options' |
message for when no choices |
Example
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()
dynamicList.render()
Kind: instance method of DynamicList
Summary: Render the list
Access: public
Example
list = new DynamicList
message: 'Foo'
emptyMessage: 'Nothing to show'
choices: [
name: 'Foo'
value: 'foo'
]
list.render()
dynamicList.addChoice(choice)
Kind: instance method of DynamicList
Summary: Add a choice
Access: public
Param | Type | Description |
---|---|---|
choice | Object |
choice |
Example
list = new DynamicList
message: 'Foo'
emptyMessage: 'Nothing to show'
choices: [
name: 'Foo'
value: 'foo'
]
list.addChoice(name: 'Bar', value: 'bar')
list.render()
dynamicList.removeChoice(choice)
Kind: instance method of DynamicList
Summary: Remove a choice
Access: public
Param | Type | Description |
---|---|---|
choice | Object |
choice |
Example
list = new DynamicList
message: 'Foo'
emptyMessage: 'Nothing to show'
choices: [
name: 'Foo'
value: 'foo'
]
list.removeChoice(name: 'Foo', value: 'foo')
list.render()
dynamicList.run() ⇒ Promise
Kind: instance method of DynamicList
Summary: Run the widget
Access: public
Fulfil: String
answer
Example
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 on GitHub and I'll be happy to help.
Tests
Run the test suite by doing:
$ gulp test
Contribute
- Issue Tracker: github.com/jviotti/inquirer-dynamic-list/issues
- Source Code: github.com/jviotti/inquirer-dynamic-list
Before submitting a PR, try to include tests, and make sure that coffeelint runs without any warning:
$ gulp lint
License
The project is licensed under the MIT license.