A prompt to select an item from a tree.
tree-select-prompt uses cli-styles to have a look & feel consistent with other prompts.
npm install tree-select-prompt
const treeSelectPrompt = require('tree-select-prompt')
const choices = [
{title: 'File "A"', value: 'file-a.jpg'},
{title: 'File "B"', value: 'file-b.pdf'},
{title: 'Directory "Stuff"', value: 'stuff', children: [
{title: 'File "C"', value: 'stuff/file-c.txt'},
{title: 'File "D"', value: 'stuff/file-d.js'}
]},
{title: 'File "E"', value: 'file-e.css'}
]
// All these are optional.
const opts = {
hint: '– Space to expand. Return to select.'
, cursor: 0
}
treeSelectPrompt('Please choose a file.', choices, opts)
.on('data', (item) => console.log('Changed to', item))
.on('abort', (item) => console.log('Aborted with', item))
.on('submit', (item) => console.log('Submitted with', item))
mail-prompt
date-prompt
number-prompt
select-prompt
multiselect-prompt
tree-select-prompt
text-prompt
cli-autocomplete
If you have a question, found a bug or want to propose a feature, have a look at the issues page.