npm.io
1.2.1 • Published 4 weeks ago

@lexjs/prompts

Licence
ISC
Version
1.2.1
Deps
2
Size
92 kB
Vulns
0
Weekly
0
Stars
1

@lexjs/prompts

Build NPM Version

Interactive prompts

Installation

npm install @lexjs/prompts
pnpm add @lexjs/prompts
yarn add @lexjs/prompts

Methods

autocomplete
import $_ from '@lexjs/prompts';

const result = await $_.autocomplete({
  message: 'Choose a city',
  name: 'city',
  choices: [
    { title: 'New York City' },
    { title: 'Toronto' },
    { title: 'London' },
    { title: 'Paris' },
  ],
});
autocomplete prompt
autocompleteMultiselect
import $_ from '@lexjs/prompts';

const result = await $_.autocompleteMultiselect({
  message: 'Pick colors',
  name: 'colors',
  choices: [
    { title: 'Red', value: '#ff0000' },
    { title: 'Green', value: '#008000' },
    { title: 'Blue', value: '#0000ff' },
    { title: 'White', value: '#ffffff' },
    { title: 'Black', value: '#000000' },
  ],
  instructions: false,
});
autocompleteMultiselect prompt
confirm
import $_ from '@lexjs/prompts';

const result = await $_.confirm({
  message: 'Confirm?',
  name: 'value',
});
confirm prompt
date
import $_ from '@lexjs/prompts';

const result = await $_.date({
  message: 'Enter a date',
  name: 'date',
});
date prompt
invisible
import $_ from '@lexjs/prompts';

const result = await $_.invisible({
  message: 'Enter password',
  name: 'password',
});
invisible prompt
list
import $_ from '@lexjs/prompts';

const result = await $_.list({
  message: 'Enter values',
  name: 'values',
  separator: ' ',
});
list prompt
multiselect
import $_ from '@lexjs/prompts';

const result = await $_.multiselect({
  message: 'Pick colors',
  name: 'colors',
  choices: [
    { title: 'Red', value: '#ff0000' },
    { title: 'Green', value: '#008000' },
    { title: 'Blue', value: '#0000ff' },
    { title: 'White', value: '#ffffff' },
    { title: 'Black', value: '#000000' },
  ],
  instructions: false,
});
multiselect prompt
number
import $_ from '@lexjs/prompts';

const result = await $_.number({
  message: 'Enter a number between 10 and 100',
  name: 'number',
  min: 10,
  max: 100,
  initial: 0,
});
number prompt
password
import $_ from '@lexjs/prompts';

const result = await $_.password({
  message: 'Enter password',
  name: 'password',
});
password prompt
select
import $_ from '@lexjs/prompts';

const result = await $_.select({
  message: 'Pick a color',
  name: 'color',
  choices: [
    { title: 'Red', value: '#ff0000' },
    { title: 'Green', value: '#008000' },
    { title: 'Blue', value: '#0000ff' },
    { title: 'White', value: '#ffffff' },
    { title: 'Black', value: '#000000' },
  ],
});
select prompt
text
import $_ from '@lexjs/prompts';

const result = await $_.text({
  message: 'What is your name?',
  name: 'value',
});
text prompt
toggle
import $_ from '@lexjs/prompts';

const result = await $_.toggle({
  message: 'Confirm?',
  name: 'value',
});
toggle prompt

Credits

This library is a wrapper around the prompts package.

Keywords