New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prompt-radio

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prompt-radio

Radio prompt. This prompt behaves like other radio-button interfaces, where only one choice is enabled whilst all others are disabled. Can be used as a standalone prompt, or with a prompt system like [Enquirer].

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

prompt-radio NPM version NPM downloads

Radio prompt. This prompt behaves like other radio-button interfaces, where only one choice is enabled whilst all others are disabled. Can be used as a standalone prompt, or with a prompt system like Enquirer.

prompt-radio example

Install

Install with npm:

$ npm install --save prompt-radio

Usage

var Enquirer = require('enquirer');
var enquirer = new Enquirer();

enquirer.register('radio', require('prompt-radio'));

Example

Enquirer supports both the declarative inquirer-style question format and a functional format using the .question method:

.question

Functional style questions.

var Enquirer = require('enquirer');
var enquirer = new Enquirer();

enquirer.register('radio', require('prompt-radio'));
enquirer.question('color', 'What is your favorite color?', {
  type: 'radio',
  default: 'blue',
  choices: ['red', 'yellow', 'blue']
});

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

Inquirer-style questions

Declarative questions format.

var Enquirer = require('enquirer');
var enquirer = new Enquirer();

enquirer.register('radio', require('prompt-radio'));

var questions = [
  {
    name: 'color',
    message: 'What is your favorite color?',
    type: 'radio',
    default: 'blue',
    choices: ['red', 'yellow', 'blue']
  }
];

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

Attribution

Partially based on the checkbox prompt in inquirer.

About

Contributing

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

Running tests

Install dev dependencies:

$ npm install -d && npm test

Author

Jon Schlinkert

License

Copyright © 2016, Jon Schlinkert. Released under the MIT license.


This file was generated by verb-generate-readme, v0.1.31, on September 21, 2016.

Keywords

FAQs

Package last updated on 07 Dec 2016

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