tty-select
TypeScript icon, indicating that this package has built-in type declarations

0.9.2 • Public • Published

tty-select

Creates async an in-line selector from a simple string on the terminal.

Install

npm install tty-select

Use

import { select } from 'tty-select';

select('Need you to say {*^yes} or {^no}').then((choice) => console.log('You said:', choice.text))

Renders on console as: "Need you to say yes or no" (with "yes" highlighted)

Symbols

  • { and } mark the boundaries of a selectable text
  • Within the selectable text: a starting * marks the pre-selected option
  • Within the selectable text: ^ marks the following character as shortcut (case-insensitive) All these symbols can be escaped by prefixing them with a backslash.

Selection

  • right or tab: moves selection to the right
  • end: moves selection to the last selectable item
  • left or shift+tab: moves selection to the left
  • home: moves selection to the first selectable item
  • enter: returns highlighted selection
  • any shortcut: selects item, and returns it

Readme

Keywords

none

Package Sidebar

Install

npm i tty-select

Weekly Downloads

0

Version

0.9.2

License

MIT

Unpacked Size

41.6 kB

Total Files

25

Last publish

Collaborators

  • gvarsanyi