Skip to content
This repository has been archived by the owner on Oct 16, 2019. It is now read-only.

derhuerst/cli-autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cli-autocomplete

Deprecated. Use the autocomplete prompt from enquirer.


A command line prompt with autocompletion. It provides just the ui, you are responsible for relevant completions.

asciicast

npm version build status dependency status dev dependency status ISC-licensed chat on gitter

cli-autocomplete uses cli-styles and prompt-skeleton to have a look & feel consistent with other prompts.

Installing

npm install cli-autocomplete

Usage

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))

Related

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.