An interactive list prompt implementation for Inquirer.
You can select a choice by using the arrow keys + Enter or by pressing the key associated with the choice.
? Choose an option: > Run command (r) Quit (q)
npm install inquirer-interactive-list-prompt
import prompt from 'inquirer-interactive-list-prompt'; (async () => { const answer = await prompt({ message: 'Select an option:', choices: [ { name: 'Run', value: 'run', key: 'r' }, { name: 'Quit', value: 'quit', key: 'q' }, ], renderSelected: choice => `❯ ${choice.name} (${choice.key})`, // optional renderUnselected: choice => ` ${choice.name} (${choice.key})`, // optional }); console.log(`Selected option: ${answer}`); })();
Prompts the user with an interactive list prompt.
Type: object
Type: string
Required: true
The message to display to the user.
Type: Array<{ name: string, value: any }>
Required: true
An array of choices to display to the user.
Type: (line: string, index: number) => string
Default: (line) => line
A function that is called to render each choice in the prompt. The function should return a string that will be displayed to the user.
Type: boolean
Default: true
Whether to hide the cursor while the prompt is active.
MIT
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4