0.1.0 • Published 8 years ago

sort-prompt v0.1.0

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

sort-prompt NPM version

Create a prompt that allows sorting a list of values.

Install

Install with npm

$ npm i sort-prompt --save

Usage

Register prompt with inquirer2 and use like other prompts.

var inquirer = require('inquirer2');
inquirer.register('sort', require('sort-prompt'));
inquirer.prompt([
  {
    type: 'sort',
    name: 'colors',
    message: 'Put the colors in order of most preferred to least.',
    choices: [
      'black',
      'blue',
      'green',
      'red',
      'white',
      'yellow'
    ]
  }
], function(answers) {
  console.log("You're preferred order of colors is:");
  console.log(answers.colors.map(function(color) {
    return colors[color](color);
  }).join('\n'));
});

The example will output these results:

image

Related projects

inquirer2: Faster, more performant fork of inquirer. | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Brian Woodward

License

Copyright © 2015 Brian Woodward Released under the MIT license.


This file was generated by verb on December 19, 2015.

0.1.0

8 years ago