Interactive prompts
npm install @lexjs/prompts
pnpm add @lexjs/prompts
yarn add @lexjs/prompts
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' },
],
});
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,
});
import $_ from '@lexjs/prompts';
const result = await $_.confirm({
message: 'Confirm?',
name: 'value',
});
import $_ from '@lexjs/prompts';
const result = await $_.date({
message: 'Enter a date',
name: 'date',
});
import $_ from '@lexjs/prompts';
const result = await $_.invisible({
message: 'Enter password',
name: 'password',
});
import $_ from '@lexjs/prompts';
const result = await $_.list({
message: 'Enter values',
name: 'values',
separator: ' ',
});
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,
});
import $_ from '@lexjs/prompts';
const result = await $_.number({
message: 'Enter a number between 10 and 100',
name: 'number',
min: 10,
max: 100,
initial: 0,
});
import $_ from '@lexjs/prompts';
const result = await $_.password({
message: 'Enter password',
name: 'password',
});
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' },
],
});
import $_ from '@lexjs/prompts';
const result = await $_.text({
message: 'What is your name?',
name: 'value',
});
import $_ from '@lexjs/prompts';
const result = await $_.toggle({
message: 'Confirm?',
name: 'value',
});
This library is a wrapper around the prompts package.