0.0.4 • Published 6 months ago

inquirer-honshin-select v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

inquirer-honshin-select

Inquirer prompt that lets you choose an item from a list and choose an action to take by pressing a key.

This project is a fork from: inquirer-action-select.

This project is pure JavaScript and in ES module.

Installation

npm i inquirer-honshin-select

Usage

const answer = await actionSelect({
    message: 'Choose a file',
    actions: [
        { value: 'open', name: 'Open', key: 'o' },
        { value: 'edit', name: 'Edit', key: 'e' },
        { value: 'delete', name: 'Delete', key: 'x' }
    ],
    choices: [
        { value: 'image.png', name: 'image.png' },
        { value: 'audio.mp3', name: 'audio.mp3' },
        { value: 'code.py',  name: 'code.py' }
    ]
)
? Choose a file Open <O> Edit <E> Delete <X>
❯ image.png
  audio.mp3
  code.py

Options

PropertyTypeRequiredDescription
messagestringyesThe question to ask
actionsArray<{ value: T, name?: string, key: string }>yesList of actions the user can take on the selected choice. name is the name of the action displayed on the prompt. value is what will be returned from the prompt. key is the key the user will press to take the specified action.
choicesArray<{ value: T, name?: string, description?: string, disabled?: boolean \| string } \| Separator>yesList of the available choices. The value will be returned as the answer, and used as display if no name is defined. Choices who're disabled will be displayed, but not selectable. The description will be displayed under the prompt when the cursor land over the choice.
defaultstringnoDefines in front of which item the cursor will initially appear. When omitted, the cursor will appear on the first selectable item.
pageSizenumbernoBy default, lists of choice longer than 7 will be paginated. Use this option to control how many choices will appear on the screen at once.
loopbooleannoDefaults to true. When set to false, the cursor will be constrained to the top and bottom of the choice list without looping.
themeSee Theming in Select docs.noCustomize look of the prompt.

Returns

PropertyTypeDescription
actionTvalue specified for the selected action
answerTvalue specified for the selected choice
0.0.4

6 months ago