Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/adam-golab/inquirer-select-line
Prompt for inquirer for inserting into array
https://github.com/adam-golab/inquirer-select-line
Last synced: 2 months ago
JSON representation
Prompt for inquirer for inserting into array
- Host: GitHub
- URL: https://github.com/adam-golab/inquirer-select-line
- Owner: adam-golab
- License: mit
- Created: 2017-05-13T17:03:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T14:13:34.000Z (almost 2 years ago)
- Last Synced: 2024-07-22T22:55:04.775Z (2 months ago)
- Language: JavaScript
- Size: 179 KB
- Stars: 12
- Watchers: 2
- Forks: 5
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# inquirer-select-line
select-line prompt for [inquirer](https://github.com/SBoudrias/Inquirer.js)
![demo](https://media.giphy.com/media/xUA7b1MxpngddUvdHW/giphy.gif)
## Installation
```
npm install --save inquirer-select-line
```## Usage
### Register the prompt
```javascript
inquirer.registerPrompt('selectLine', require('inquirer-select-line'));inquirer.prompt({
type: 'selectLine',
message: message,
name: name,
choices: choices,
placeholder: placeholder,
})
```Change `selectLine` to whatever you might prefer.
### Options
-**message** : (*String*|*Function*) The question to print. If defined as a function, the first parameter will be the current inquirer session answers.-**name** : (*String*) The name to use when storing the answer in the answers hash. If the name contains periods, it will define a path in the answers hash.
-**choices**: (*Array*|*Function*) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers. Array values have to be simple strings. The choices array can also contain [a Separator](https://github.com/SBoudrias/Inquirer.js/#separator).
-**placeholder** (*String*|*Function*) The name to display as a placeholder for chosen line. If defined as a function, the first parameter will be index of currently chosen answer. (optional) default: `INSERT HERE`.
#### Example
```javascript
inquirer.registerPrompt('selectLine', require('inquirer-selectLine'));
inquirer.prompt([{
type: 'selectLine',
message: 'Where add line?',
name: 'line',
choices: ['first', 'second', 'third', 'fourth'],
}]).then(function(answers) {
console.log('Chosen line: ' answers.line);
/*
OUTPUT :
Chosen line: 2
*/
});
```## License
MIT