A small Inquirer.js-based CLI prompt to make searcheable, dynamic lists a bit better. This was largely inspired by shortcomings of existing similar Inquirer plugins, with the aim of making a truly comprehensive and extensible module of my (and hopefully your) list prompt needs.
// For the very latest
yarn add https://github.com/mcataford/searchable-list-prompt#main
// For the latest published
yarn add searchable-list-prompt
import searchableListPrompt from 'searcheable-list-prompt'
const theChosenOne = await searchableListPrompt({
message: 'Pick one:',
choices: ['Luke', 'Anakin', 'Frodo']
})
You can enter regular expressions in the prompt to search through choices. If a regexp is incomplete or invalid, it's taken as-is as a search string.
choices
is an array of items used to populate the prompt's list. It can be a list of strings, numbers or objects. In the case of object choices, they should have same format as the choices
parameter described by Inquirer.
pageSize
is a number that describes the number of items in the visible window. If the number of choices is greater than the page size, only pageSize
elements will be rendered on screen and the rest can be access via scrolling. The scrolling wraps around.
You can pass your own "no matches" message as a string via noMatchesMessage
. The default is otherwise No matches
.
You can pass in a message to be displayed before the prompt via message
You can pass a string via selectionMarker
that will appear on the left of the choice you are currently on.