Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prompt-rawlist

Package Overview
Dependencies
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prompt-rawlist

Rawlist prompt. Can be used as a standalone prompt, or with a prompt system like [Enquirer].

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

prompt-rawlist NPM version NPM monthly downloads NPM total downloads Linux Build Status

Rawlist prompt. Can be used as a standalone prompt, or with a prompt system like Enquirer.

prompt-rawlist example

Install

Install with npm:

$ npm install --save prompt-rawlist

Usage

var RawList = require('prompt-rawlist');
var prompt = new RawList({
  name: 'colors',
  message: 'Favorite flavor?',
  choices: [
    'chocolate',
    'strawberry',
    'vanilla'
  ]
});

// async
prompt.ask(function(answer) {
  console.log(answer);
  // chocolate
});

// promise
prompt.run()
  .then(function(answer) {
    console.log(answer);
    // chocolate
  });

Enquirer usage

Register as a plugin with enquirer:

var Enquirer = require('enquirer');
var enquirer = new Enquirer();
enquirer.register('rawlist', require('prompt-rawlist'));

Declarative format

Define questions using a declarative style, similar to Inquirer.

var questions = [
  {
    type: 'rawlist',
    name: 'dinner',
    message: 'What would you like to do?',
    choices: [
      'Order a pizza',
      'Make a reservation',
      enquirer.separator(),,
      'Ask opening hours',
      'Talk to the receptionist'
    ]
  },
  {
    type: 'rawlist',
    name: 'size',
    message: 'What size would you like?',
    choices: ['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro']
  }
];

enquirer.ask(questions)
  .then(function (answers) {
    console.log(answers);
  });

Expressive format

Register questions using enquirer's .question method:

enquirer.question('dinner', {
  type: 'rawlist',
  message: 'What would you like to do?',
  choices: [
    'Order a pizza',
    'Make a reservation',
    enquirer.separator(),
    'Ask opening hours',
    'Talk to the receptionist'
  ]
});

enquirer.question('size', 'What size would you like?', {
  type: 'rawlist',
  choices: ['Jumbo', 'Large', 'Standard', 'Medium', 'Small', 'Micro']
});

enquirer.ask(['dinner', 'size'])
  .then(function (answers) {
    console.log(answers);
    //=> { dinner: 'Order a pizza', size: 'Large' }
  });

Attribution

Originally based on the rawlist prompt in inquirer.

About

Contributing

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

Running tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test

Author

Jon Schlinkert

License

Copyright © 2017, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.6.0, on June 04, 2017.

Keywords

FAQs

Package last updated on 05 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc