enquirer-prompt-confirm

0.1.2 • Public • Published

enquirer-prompt-confirm NPM version NPM downloads

Adds confirm (yes/no) prompt support to Enquirer.

confirm prompt example

Install

Install with npm:

$ npm install --save enquirer-prompt-confirm

Usage

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

Example

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

Single question

Ask one question using the .prompt method:

var Enquirer = require('enquirer');
var enquirer = new Enquirer();
 
enquirer.register('checkbox', require('enquirer-prompt-confirm'));
 
enquirer.question('chocolate', 'Like chocolate?', {type: 'confirm'});
enquirer.question('vanilla', 'Like vanilla?', {type: 'confirm'});
 
enquirer.prompt('vanilla')
  .then(function(answers) {
    console.log(answers)
  });

Functional

Functional style questions.

var Enquirer = require('enquirer');
var enquirer = new Enquirer();
 
enquirer.register('checkbox', require('enquirer-prompt-confirm'));
 
enquirer.question('chocolate', 'Like chocolate?', {type: 'confirm'});
enquirer.question('vanilla', 'Like vanilla?', {type: 'confirm'});
 
enquirer.ask(['chocolate', 'vanilla'])
  .then(function(answers) {
    console.log(answers)
  });

Declarative

Inquirer-style questions format.

var Enquirer = require('enquirer');
var enquirer = new Enquirer();
 
enquirer.register('checkbox', require('enquirer-prompt-confirm'));
 
var questions = [
  {type: 'confirm', name: 'chocolate', message: 'Like chocolate?'},
  {type: 'confirm', name: 'vanilla', message: 'Like vanilla?'}
];
 
enquirer.ask(questions)
  .then(function(answers) {
    console.log(answers)
  });

Attribution

Based on the confirm prompt in inquirer.

About

Related projects

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.30, on August 30, 2016.

Package Sidebar

Install

npm i enquirer-prompt-confirm

Weekly Downloads

1

Version

0.1.2

License

MIT

Last publish

Collaborators

  • jonschlinkert