Build interactive command line interfaces with ease.
This package only works in a TTY-enabled environment. If the package is used in a non-TTY environment, it will print a warning that can be suppressed by setting the PROMPTKIT_DISABLE_TTY_WARNING
environment variable to true
.
To install the latest version, run:
npm install @xandrrrr/prompt-kit
const { SelectionBuilder } = require('@xandrrrr/prompt-kit');
const selection = new SelectionBuilder()
.setPrompt('Select a color')
.setOptions([
{ option: 'red', value: 'red' },
{ option: 'green', value: 'green' },
{ option: 'blue', value: 'blue' },
])
.build()
.then((selected) => {
console.log(`You selected ${selected.map((s) => s.value).join(', ')}`);
});
You can find the documentation here.