Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including choices with all npm packages installed. Try it out:

var choices = require("choices")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

choices v0.1.3

Choices - an API for prompting the user with multiple choices

Choices

Choices is an API for prompting the user with multiple-choices.

Choices are displayed in a numbered list, user is prompted with a message and options repeatedly until they make a choice or cancel (q, esc, ctrl+c).

If the user cancels, your callback will receive null as the option index.

Install

npm install choices

Example

var choices = require('choices');
var options = ['First Option', 'Second option', 'Third option'];
choices('Pick an option', options, function(idx) {
  console.log('You picked ' + options[idx]);
});
  [1]: First option
  [2]: Second option
  [3]: Third option
Pick an option>> 2
You picked Second option
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free