Deprecated. Use the autocomplete prompt from enquirer
.
A command line prompt with autocompletion. It provides just the ui, you are responsible for relevant completions.
cli-autocomplete uses cli-styles and prompt-skeleton to have a look & feel consistent with other prompts.
npm install cli-autocomplete
const autocompletePrompt = require('cli-autocomplete')
const colors = [
{title: 'red', value: '#f00'},
{title: 'yellow', value: '#ff0'},
{title: 'green', value: '#0f0'},
{title: 'blue', value: '#00f'},
{title: 'black', value: '#000'},
{title: 'white', value: '#fff'}
]
const suggestColors = (input) => Promise.resolve(colors
.filter((color) => color.title.slice(0, input.length) === input))
autocompletePrompt('What is your favorite color?', suggestColors)
.on('data', (e) => console.log('Interim value', e.value))
.on('abort', (v) => console.log('Aborted with', v))
.on('submit', (v) => console.log('Submitted with', v))
If you have a question, found a bug or want to propose a feature, have a look at the issues page.