searchable-list-prompt

0.0.2 • Public • Published

searchable-list-prompt

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.

Install

// For the very latest
yarn add https://github.com/mcataford/searchable-list-prompt#main

// For the latest published
yarn add searchable-list-prompt

Usage

import searchableListPrompt from 'searcheable-list-prompt'

const theChosenOne = await searchableListPrompt({
    message: 'Pick one:',
    choices: ['Luke', 'Anakin', 'Frodo']
})

Features

Searching

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

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.

Page Size

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.

Customizable messaging

When no matches exist

You can pass your own "no matches" message as a string via noMatchesMessage. The default is otherwise No matches.

Prompt

You can pass in a message to be displayed before the prompt via message

Selection marker

You can pass a string via selectionMarker that will appear on the left of the choice you are currently on.

Package Sidebar

Install

npm i searchable-list-prompt

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

12.4 kB

Total Files

7

Last publish

Collaborators

  • mcataford