Comparing version 2.0.2 to 2.0.3
45
index.js
@@ -64,10 +64,8 @@ 'use strict'; | ||
* | ||
* (async() => { | ||
* const response = await enquirer.prompt({ | ||
* type: 'input', | ||
* name: 'username', | ||
* message: 'What is your username?' | ||
* }); | ||
* console.log(response); | ||
* })(); | ||
* const response = await enquirer.prompt({ | ||
* type: 'input', | ||
* name: 'username', | ||
* message: 'What is your username?' | ||
* }); | ||
* console.log(response); | ||
* ``` | ||
@@ -158,19 +156,2 @@ * @name prompt | ||
/** | ||
* Programmatically cancel all prompts. | ||
* | ||
* ```js | ||
* const Enquirer = require('enquirer'); | ||
* const enquirer = new Enquirer(); | ||
* | ||
* | ||
* | ||
* enquirer.use(plugin); | ||
* ``` | ||
* @name use | ||
* @param {Function} `plugin` Plugin function that takes an instance of Enquirer. | ||
* @return {Object} Returns the Enquirer instance. | ||
* @api public | ||
*/ | ||
submit(value, state) { | ||
@@ -219,10 +200,8 @@ this.submitted = true; | ||
* const { prompt } = require('enquirer'); | ||
* (async() => { | ||
* const response = await prompt({ | ||
* type: 'input', | ||
* name: 'username', | ||
* message: 'What is your username?' | ||
* }); | ||
* console.log(response); | ||
* })(); | ||
* const response = await prompt({ | ||
* type: 'input', | ||
* name: 'username', | ||
* message: 'What is your username?' | ||
* }); | ||
* console.log(response); | ||
* ``` | ||
@@ -229,0 +208,0 @@ * @name Enquirer#prompt |
@@ -26,3 +26,3 @@ 'use strict'; | ||
this.state = new State(this); | ||
this.initial = options.initial; | ||
this.initial = [options.initial, options.default].find(v => v != null); | ||
this.stdout = options.stdout || process.stdout; | ||
@@ -29,0 +29,0 @@ this.stdin = options.stdin || process.stdin; |
@@ -7,3 +7,2 @@ 'use strict'; | ||
let val = input.toLowerCase(); | ||
return str => { | ||
@@ -10,0 +9,0 @@ let s = str.toLowerCase(); |
@@ -47,5 +47,3 @@ 'use strict'; | ||
let value = choice.editable ? symbol : super.indicator(choice, i); | ||
let res = await this.resolve(value, this.state, choice, i) || ''; | ||
// return colors.unstyle(res); | ||
return res; | ||
return await this.resolve(value, this.state, choice, i) || ''; | ||
} | ||
@@ -52,0 +50,0 @@ |
@@ -21,2 +21,3 @@ 'use strict'; | ||
define('Sort', () => require('./sort')); | ||
define('Survey', () => require('./survey')); | ||
define('Text', () => require('./text')); |
@@ -32,3 +32,3 @@ 'use strict'; | ||
async renderChoice(item, i) { | ||
await this.onChoice(item, i); | ||
// await this.onChoice(item, i); | ||
@@ -35,0 +35,0 @@ let focused = this.index === i; |
@@ -9,2 +9,3 @@ 'use strict'; | ||
this.pos = { h: 0, get v() { return this.index; } }; | ||
this.term = process.TERM_PROGRAM; | ||
@@ -76,5 +77,7 @@ if (!this.options.header) { | ||
let focused = this.index === i; | ||
let ln = this.symbols.line.repeat(9); | ||
let n = this.term !== 'Hyper' ? 9 : 8; | ||
let s = this.term !== 'Hyper' ? '' : ' '; | ||
let ln = this.symbols.line.repeat(n); | ||
let sp = ' '.repeat(9); | ||
let dot = enabled => enabled ? this.styles.success('◉') : '◯'; | ||
let dot = enabled => (enabled ? this.styles.success('◉') : '◯') + s; | ||
@@ -116,3 +119,2 @@ let num = i + 1 + '.'; | ||
return ''; | ||
// return this.styles.muted('(Please rate your experience)'); | ||
} | ||
@@ -119,0 +121,0 @@ |
@@ -10,8 +10,9 @@ 'use strict'; | ||
super(options); | ||
this.cursorHide(); | ||
this.maxChoices = options.maxChoices || Infinity; | ||
this.multiple = options.multiple || false; | ||
this.initial = options.initial || 0; | ||
this.delay = options.delay || 250; | ||
this.longest = 0; | ||
this.cursorHide(); | ||
this.fns = []; | ||
this.num = ''; | ||
} | ||
@@ -74,2 +75,5 @@ | ||
if (ele.normalized) return ele; | ||
ele.normalized = true; | ||
ele.role = ele.role || 'option'; | ||
@@ -205,25 +209,53 @@ | ||
number(n) { | ||
let i = Number(n); | ||
if (i > this.choices.length - 1) return this.alert(); | ||
this.num += n; | ||
let focused = this.focused; | ||
let choice = this.choices.find(ch => i === ch.index); | ||
let number = num => { | ||
let i = Number(num); | ||
if (i > this.choices.length - 1) return this.alert(); | ||
if (this.visible.indexOf(choice) === -1) { | ||
let choices = reorder(this.choices); | ||
let actualIdx = choices.indexOf(choice); | ||
let focused = this.focused; | ||
let choice = this.choices.find(ch => i === ch.index); | ||
if (focused.index > actualIdx) { | ||
let start = choices.slice(actualIdx, actualIdx + this.limit); | ||
let end = choices.filter(ch => !start.includes(ch)); | ||
this.choices = start.concat(end); | ||
} else { | ||
let pos = actualIdx - this.limit + 1; | ||
this.choices = choices.slice(pos).concat(choices.slice(0, pos)); | ||
if (this.visible.indexOf(choice) === -1) { | ||
let choices = reorder(this.choices); | ||
let actualIdx = choices.indexOf(choice); | ||
if (focused.index > actualIdx) { | ||
let start = choices.slice(actualIdx, actualIdx + this.limit); | ||
let end = choices.filter(ch => !start.includes(ch)); | ||
this.choices = start.concat(end); | ||
} else { | ||
let pos = actualIdx - this.limit + 1; | ||
this.choices = choices.slice(pos).concat(choices.slice(0, pos)); | ||
} | ||
}; | ||
this.index = this.choices.indexOf(choice); | ||
this.toggle(this.focused); | ||
return this.render(); | ||
}; | ||
clearTimeout(this.numberTimeout); | ||
return new Promise(resolve => { | ||
let len = this.choices.length; | ||
let num = this.num; | ||
let handle = (val = false, res) => { | ||
clearTimeout(this.numberTimeout); | ||
if (val) number(num); | ||
this.num = ''; | ||
resolve(res); | ||
}; | ||
if (num === '0' || (num.length === 1 && Number(num + '0') > len)) { | ||
return handle(true); | ||
} | ||
} | ||
this.index = this.choices.indexOf(choice); | ||
this.toggle(this.focused); | ||
return this.render(); | ||
if (Number(num) > len) { | ||
return handle(false, this.alert()); | ||
} | ||
this.numberTimeout = setTimeout(() => handle(true), this.delay); | ||
}); | ||
} | ||
@@ -230,0 +262,0 @@ |
@@ -46,4 +46,5 @@ 'use strict'; | ||
let message = await this.message(); | ||
let hint = this.styles.muted(this.default); | ||
let promptLine = this.state.prompt = [prefix, message, separator].join(' '); | ||
let promptLine = this.state.prompt = [prefix, message, hint, separator].join(' '); | ||
@@ -50,0 +51,0 @@ let header = await this.header(); |
{ | ||
"name": "enquirer", | ||
"description": "Stylish, intuitive and user-friendly prompt system. Fast and lightweight enough for small projects, powerful and extensible enough for the most advanced use cases.", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"homepage": "https://github.com/enquirer/enquirer", | ||
@@ -6,0 +6,0 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", |
419
README.md
@@ -13,5 +13,2 @@ <h1 align="center">Enquirer</h1> | ||
</a> | ||
<a href="https://packagephobia.now.sh/result?p=enquirer"> | ||
<img src="https://packagephobia.now.sh/badge?p=enquirer" alt="install size"> | ||
</a> | ||
</p> | ||
@@ -28,7 +25,13 @@ | ||
<br> | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/survey-prompt.gif" alt="Enquirer Survey Prompt" width="750"> | ||
</p> | ||
<br> | ||
<br> | ||
Enquirer is fast, easy to use, and lightweight enough for small projects, while also being powerful and customizable enough for the most advanced use cases. | ||
Created by [jonschlinkert](https://github.com/jonschlinkert) and [doowb](https://github.com/doowb), Enquirer is fast, easy to use, and lightweight enough for small projects, while also being powerful and customizable enough for the most advanced use cases. | ||
* **Fast** - [Loads in ~4ms](#performance) (that's about _3-4 times faster than a [single frame of a HD movie](http://www.endmemo.com/sconvert/framespersecondframespermillisecond.php) at 60fps_) | ||
* **Fast** - [Loads in ~4ms](#-performance) (that's about _3-4 times faster than a [single frame of a HD movie](http://www.endmemo.com/sconvert/framespersecondframespermillisecond.php) at 60fps_) | ||
* **Lightweight** - Only [one dependency](https://github.com/doowb/ansi-colors). | ||
@@ -46,3 +49,18 @@ * **Easy to use** - Uses promises and async/await to make prompts easy to create and use. | ||
<br> | ||
<hr> | ||
## ❯ Getting started | ||
Get started with Enquirer, the most powerful and easy-to-use Node.js library for creating interactive CLI prompts. | ||
* [Install](#-install) | ||
* [Usage](#-usage) | ||
* [Enquirer API](#-enquirer-api) | ||
* [Prompts](#-prompts) | ||
* [Types](#-types) | ||
* [Keypresses](#-keypresses) | ||
* [Options](#-options) | ||
* [Release History](#-release-history) | ||
* [Performance](#-performance) | ||
* [About](#-about) | ||
<br> | ||
@@ -55,3 +73,3 @@ | ||
```sh | ||
$ npm install --save enquirer@beta | ||
$ npm install --save enquirer | ||
``` | ||
@@ -62,19 +80,3 @@ | ||
<br> | ||
<hr> | ||
<br> | ||
## ❯ Getting started | ||
Get started with Enquirer, the most powerful and easy-to-use Node.js library for creating interactive CLI prompts. | ||
* [Usage](#-usage) | ||
* [API](#-api) | ||
* [Options](#-options) | ||
* [Performance](#-performance) | ||
* [Credit](#-credit) | ||
<br> | ||
<hr> | ||
<br> | ||
## ❯ Usage | ||
@@ -84,3 +86,3 @@ | ||
Pass a [question object](#prompt-options) to run a single prompt. | ||
The easiest way to get started with enquirer is to pass a [question object](#prompt-options) to the `prompt` method. | ||
@@ -125,6 +127,4 @@ ```js | ||
<br> | ||
<hr> | ||
<br> | ||
## ❯ API | ||
## ❯ Enquirer API | ||
@@ -165,3 +165,3 @@ ### [Enquirer](index.js#L19) | ||
### [prompt](index.js#L79) | ||
### [prompt](index.js#L77) | ||
@@ -181,13 +181,11 @@ Prompt function that takes a "question" object or array of question objects, and returns an object with responses from the user. | ||
(async() => { | ||
const response = await enquirer.prompt({ | ||
type: 'input', | ||
name: 'username', | ||
message: 'What is your username?' | ||
}); | ||
console.log(response); | ||
})(); | ||
const response = await enquirer.prompt({ | ||
type: 'input', | ||
name: 'username', | ||
message: 'What is your username?' | ||
}); | ||
console.log(response); | ||
``` | ||
### [use](index.js#L152) | ||
### [use](index.js#L150) | ||
@@ -212,10 +210,10 @@ Use an enquirer plugin. | ||
### [use](index.js#L174) | ||
### [Enquirer#prompt](index.js#L211) | ||
Programmatically cancel all prompts. | ||
Prompt function that takes a "question" object or array of question objects, and returns an object with responses from the user. | ||
**Params** | ||
* `plugin` **{Function}**: Plugin function that takes an instance of Enquirer. | ||
* `returns` **{Object}**: Returns the Enquirer instance. | ||
* `questions` **{Array|Object}**: Options objects for one or more prompts to run. | ||
* `returns` **{Promise}**: Promise that returns an "answers" object with the user's responses. | ||
@@ -225,43 +223,277 @@ **Example** | ||
```js | ||
const Enquirer = require('enquirer'); | ||
const enquirer = new Enquirer(); | ||
enquirer.use(plugin); | ||
const { prompt } = require('enquirer'); | ||
const response = await prompt({ | ||
type: 'input', | ||
name: 'username', | ||
message: 'What is your username?' | ||
}); | ||
console.log(response); | ||
``` | ||
### [Enquirer#prompt](index.js#L232) | ||
## ❯ Prompts | ||
Prompt function that takes a "question" object or array of question objects, and returns an object with responses from the user. | ||
* [AutoComplete](#autocomplete-prompt) | ||
* [Confirm](#confirm-prompt) | ||
* [Input](#input-prompt) | ||
* [Invisible](#invisible-prompt) | ||
* [List](#list-prompt) | ||
* [Multiselect](#multiselect-prompt) | ||
* [Number](#number-prompt) | ||
* [Password](#password-prompt) | ||
* [Select](#select-prompt) | ||
* [Snippet](#snippet-prompt) | ||
* [Sort](#sort-prompt) | ||
* [Survey](#survey-prompt) | ||
* `Text` (alias for [Input](#input)) | ||
**Params** | ||
### AutoComplete Prompt | ||
* `questions` **{Array|Object}**: Options objects for one or more prompts to run. | ||
* `returns` **{Promise}**: Promise that returns an "answers" object with the user's responses. | ||
Prompt that auto-completes as the user types, and returns the selected value as a string. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/autocomplete-prompt.gif" alt="Enquirer Autocomplete Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [select prompt](#select-prompt) | ||
* [multiselect prompt](#multiselect-prompt) | ||
* [survey prompt](#survey-prompt) | ||
### Confirm Prompt | ||
Prompt that returns `true` or `false`. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/confirm-prompt.gif" alt="Enquirer Confirm Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [input prompt](#input-prompt) | ||
* [number prompt](#number-prompt) | ||
* [password prompt](#password-prompt) | ||
### Input Prompt | ||
Prompt that takes user input and returns a string. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/input-prompt.gif" alt="Enquirer Input Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [confirm prompt](#confirm-prompt) | ||
* [number prompt](#number-prompt) | ||
* [password prompt](#password-prompt) | ||
### Invisible Prompt | ||
Prompt that takes user input, hides it from the terminal, and returns a string. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/invisible-prompt.gif" alt="Enquirer Invisible Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [password prompt](#password-prompt) | ||
* [input prompt](#input-prompt) | ||
### List Prompt | ||
Prompt that returns a list of values, created by splitting the user input. The default split character is `,` with optional trailing whitespace. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/list-prompt.gif" alt="Enquirer List Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [sort prompt](#sort-prompt) | ||
* [select prompt](#select-prompt) | ||
### Multiselect Prompt | ||
Prompt that allows the user to select multiple items from a list of options. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/multiselect-prompt.gif" alt="Enquirer Multiselect Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [select prompt](#select-prompt) | ||
* [autocomplete prompt](#autocomplete-prompt) | ||
### Number Prompt | ||
Prompt that takes a number as input. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/number-prompt.gif" alt="Enquirer Number Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [input prompt](#input-prompt) | ||
* [confirm prompt](#confirm-prompt) | ||
### Password Prompt | ||
Prompt that takes user input and masks it in the terminal. Also see the [invisible prompt](#invisible-prompt) | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/password-prompt.gif" alt="Enquirer Password Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [input prompt](#input-prompt) | ||
* [invisible prompt](#invisible-prompt) | ||
### Select Prompt | ||
Prompt that allows the user to select from a list of options. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/select-prompt.gif" alt="Enquirer Select Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [autocomplete prompt](#autocomplete-prompt) | ||
* [multiselect prompt](#multiselect-prompt) | ||
### Snippet Prompt | ||
Prompt that allows the user to replace placeholders in a snippet of code or text. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/snippet-prompt.gif" alt="Prompts" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [survey prompt](#survey-prompt) | ||
* [autocomplete prompt](#autocomplete-prompt) | ||
### Sort Prompt | ||
Prompt that allows the user to sort items in a list. | ||
**Example** | ||
```js | ||
const { prompt } = require('enquirer'); | ||
(async() => { | ||
const response = await prompt({ | ||
type: 'input', | ||
name: 'username', | ||
message: 'What is your username?' | ||
}); | ||
console.log(response); | ||
})(); | ||
``` | ||
In this [example](https://github.com/enquirer/enquirer/raw/master/examples/sort/prompt.js), custom styling is applied to the returned values to make it easier to see what's happening. | ||
## Prompt API | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/sort-prompt.gif" alt="Enquirer Sort Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [list prompt](#list-prompt) | ||
* [select prompt](#select-prompt) | ||
### Survey Prompt | ||
Prompt that allows the user to provide feedback for a list of questions. | ||
<p align="center"> | ||
<img src="https://github.com/enquirer/enquirer/raw/master/media/survey-prompt.gif" alt="Enquirer Survey Prompt" width="750"> | ||
</p> | ||
**Related prompts** | ||
* [snippet prompt](#snippet-prompt) | ||
* [select prompt](#select-prompt) | ||
## ❯ Types | ||
* [ArrayPrompt](#arrayprompt) | ||
* [BooleanPrompt](#booleanprompt) | ||
* DatePrompt (Coming Soon!) | ||
* [NumberPrompt](#numberprompt) | ||
* [StringPrompt](#stringprompt) | ||
### ArrayPrompt | ||
todo | ||
### BooleanPrompt | ||
todo | ||
### NumberPrompt | ||
todo | ||
### StringPrompt | ||
todo | ||
## ❯ Keypresses | ||
### All prompts | ||
Key combinations that may be used with all prompts. | ||
| **command** | **description** | | ||
| ---: | --- | | ||
| <kbd>ctrl</kbd>+<kbd>a</kdb> | Move the cursor to the first character in user input. | | ||
| <kbd>ctrl</kbd>+<kbd>c</kbd> | Cancel the prompt. | | ||
| <kbd>ctrl</kbd>+<kbd>g</kdb> | Reset the prompt to its initial state. | | ||
### Move cursor | ||
Key combinations that may be used on prompts that support user input, such as the [input prompt](#input-prompt), [password prompt](#password-prompt), and [invisible prompt](#invisible-prompt)). | ||
| **command** | **description** | | ||
| ---: | --- | | ||
| <kbd>left</kbd> | Move the cursor forward one character. | | ||
| <kbd>right</kbd> | Move the cursor back one character. | | ||
| <kbd>ctrl</kbd>+<kbd>a</kbd> | Move cursor to the start of the line | | ||
| <kbd>ctrl</kbd>+<kbd>e</kbd> | Move cursor to the end of the line | | ||
| <kbd>ctrl</kbd>+<kbd>b</kbd> | Move cursor back one character | | ||
| <kbd>ctrl</kbd>+<kbd>f</kbd> | Move cursor forward one character | | ||
| <kbd>ctrl</kbd>+<kbd>x</kbd> | Toggle between first and cursor position | | ||
## Select choices | ||
These key combinations may be used on prompts that support _multiple_ choices, such as the [multiselect prompt](#multiselect-prompt), or the [select prompt](#select-prompt) when the `multiple` options is true. | ||
| **command** | **description** | | ||
| ---: | --- | | ||
| <kbd>space</kbd> | Toggle the currently selected choice when `options.multiple` is true. | | ||
| <kbd>number</kbd> | Move the pointer to the choice at the given index. Also toggles the selected choice when `options.multiple` is true. | | ||
| <kbd>a</kbd> | Toggle all choices to be enabled or disabled. | | ||
| <kbd>i</kbd> | Invert the current selection of choices. | | ||
| <kbd>g</kbd> | Toggle the current choice group. | | ||
### Hide/show choices | ||
| **command** | **description** | | ||
| ---: | --- | | ||
| <kbd>fn</kbd>+<kbd>up</kbd> | Decrease the number of visible choices by one. | | ||
| <kbd>fn</kbd>+<kbd>down</kbd> | Increase the number of visible choices by one. | | ||
### Move/lock Pointer | ||
| **command** | **description** | | ||
| ---: | --- | | ||
| <kbd>number</kbd> | Move the pointer to the choice at the given index. Also toggles the selected choice when `options.multiple` is true. | | ||
| <kbd>up</kbd> | Move the pointer up. | | ||
| <kbd>down</kbd> | Move the pointer down. | | ||
| <kbd>ctrl</kbd>+<kbd>a</kbd> | Move the pointer to the first _visible_ choice. | | ||
| <kbd>ctrl</kbd>+<kbd>e</kbd> | Move the pointer to the last _visible_ choice. | | ||
| (mac) <kbd>fn</kbd>+<kbd>left</kbd> / (win) <kbd>home</kbd> | Move the pointer to the first choice in the choices array. | | ||
| (mac) <kbd>fn</kbd>+<kbd>right</kbd> / (win) <kbd>end</kbd> | Move the pointer to the last choice in the choices array. | | ||
| <kbd>shift</kbd>+<kbd>up</kbd> | Scroll up one choice without changing pointer position (locks the pointer while scrolling). | | ||
| <kbd>shift</kbd>+<kbd>down</kbd> | Scroll down one choice without changing pointer position (locks the pointer while scrolling). | | ||
<br> | ||
<hr> | ||
<br> | ||
## ❯ Options | ||
### Enquirer options | ||
TODO | ||
### Prompt options | ||
@@ -278,3 +510,3 @@ | ||
format: function | async function, | ||
answer: function | async function, | ||
result: function | async function, | ||
validate: function | async function | ||
@@ -286,10 +518,12 @@ } | ||
| --- | --- | --- | | ||
| `type` (required) | `string`, `function` | Enquirer uses this value to determine the type of prompt to run, but it's optional when prompts are run directly. | | ||
| `name` (required) | `string`, `function` | Used as the key for the answer on the returned values (answers) object. | | ||
| `message` (required) | `string`, `function` | The message to display when the prompt is rendered in the terminal. | | ||
| `initial` (optional) | `string`, `function` | The default value to return if the user does not supply a value. | | ||
| `format` (optional) | `function` | Function to format user input in the terminal. | | ||
| `result` (optional) | `function` | Function to format the final, submitted value before it's returned. | | ||
| `validate` (optional) | `function` | Function to validate the submitted value before it's returned. This function may return a boolean or a string. If a string is returned it will be used as the validation error message. | | ||
| `type` | `string\|function` | Enquirer uses this value to determine the type of prompt to run, but it's optional when prompts are run directly. | | ||
| `name` | `string\|function` | Used as the key for the answer on the returned values (answers) object. | | ||
| `message` | `string\|function` | The message to display when the prompt is rendered in the terminal. | | ||
| `initial` | `string\|function` | The default value to return if the user does not supply a value. | | ||
| `format` | `function` | Function to format user input in the terminal. | | ||
| `result` | `function` | Function to format the final submitted value before it's returned. | | ||
| `validate` | `function` | Function to validate the submitted value before it's returned. This function may return a boolean or a string. If a string is returned it will be used as the validation error message. | | ||
_(`type`, `name` and `message` are required)._ | ||
**Example** | ||
@@ -320,3 +554,2 @@ | ||
disabled: boolean | string | undefined; | ||
enabled: boolean | undefined; | ||
} | ||
@@ -327,12 +560,14 @@ ``` | ||
| --- | --- | --- | | ||
| `name` | `string` | The unique id for a choice | | ||
| `message` | `string` | The message to display | | ||
| `value` | `string` | The value to return if the choice is selected | | ||
| `alias` | `string` | Single character to use when keypress shortcuts are supported | | ||
| `hint` | `string` | | | ||
| `error` | `string` | | | ||
| `disabled` | `boolean` | | | ||
| `separator` | `boolean` | | | ||
| `selected` | `boolean` | | | ||
| `name` | `string` | The unique key to identify a choice | | ||
| `message` | `string` | The message to display in the terminal | | ||
| `value` | `string` | An optional value to associate with the choice. This is useful for creating key-value pairs from user choices. | | ||
| `hint` | `string` | Value to display to provide user help next to a choice. | | ||
| `disabled` | `boolean\|string` | Disable a choice so that it cannot be selected. This value may either be `true`, `false`, or a message to display. | | ||
<br> | ||
## ❯ Release History | ||
Please see [CHANGELOG.md](CHANGELOG.md). | ||
## ❯ Performance | ||
@@ -352,8 +587,6 @@ | ||
## ❯ Credit | ||
<br> | ||
Thanks to [derhuerst](https://github.com/derhuerst), creator of prompt libraries such as [prompt-skeleton](https://github.com/derhuerst/prompt-skeleton), which influenced some of the concepts we used in our prompts. | ||
## ❯ About | ||
## About | ||
<details> | ||
@@ -407,5 +640,9 @@ <summary><strong>Contributing</strong></summary> | ||
### Credit | ||
Thanks to [derhuerst](https://github.com/derhuerst), creator of prompt libraries such as [prompt-skeleton](https://github.com/derhuerst/prompt-skeleton), which influenced some of the concepts we used in our prompts. | ||
### License | ||
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
Released under the [MIT License](LICENSE). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138311
43
3097
631