Plugin for base-methods that adds methods for prompting the user and storing the answers on a project-by-project basis.
You might also be interested in data-store.
Table of Contents(TOC generated by verb using markdown-toc)
InstallInstall with npm:
Usage$ npm install --save base-questions
Try running the actual examples if it helps to see the following example in action.
API .confirmvar questions = require('base-questions');
var assemble = require('assemble-core');
var store = require('base-store');
var argv = require('base-argv');
Â
var app = assemble();
app.use(store());
app.use(argv());
Â
var argv = app.argv(process.argv.slice(2));
app.use(questions(app, argv.options));
Â
app.task('ask', function (cb) {
  app.ask(function (err, answers) {
    if (err) return cb(err);
    console.log(answers);
    cb();
  });
});
Â
app.task('a', function (cb) {
  console.log('task > a!');
  cb();
});
Â
app.task('b', function (cb) {
  console.log('task > b!');
  cb();
});
Â
app.task('c', function (cb) {
  console.log('task > c!');
  cb();
});
Â
app.task('choices', function (cb) {
  app.choices('run', ['a', 'b', 'c'], function (err, answers) {
    if (err) return cb(err);
    if (!answers.run.length) return cb();
    app.build(answers.run, cb);
  });
});
Â
app.build('choices', function(err) {
  if (err) return console.log(err);
  console.log('done!');
});
Create a confirm
question.
Params
name
{String}: Question namemsg
{String}: Question messagequeue
{String|Array}: Name or array of question names.options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
.choicesapp.confirm('file', 'Want to generate a file?');
Â
app.question({
  name: 'file',
  message: 'Want to generate a file?',
  type: 'confirm'
});
Create a "choices" question from an array.
Params
name
{String}: Question namemsg
{String}: Question messagechoices
{Array}: Choice itemsqueue
{String|Array}: Name or array of question names.options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
.questionapp.choices('color', 'Favorite color?', ['blue', 'orange', 'green']);
Â
app.choices('color', {
  message: 'Favorite color?',
  choices: ['blue', 'orange', 'green']
});
Â
app.choices({
  name: 'color',
  message: 'Favorite color?',
  choices: ['blue', 'orange', 'green']
});
Add a question to be asked by the .ask
method.
Params
name
{String}: Question namemsg
{String}: Question messagevalue
{Object|String}: Question object, message (string), or options object.locale
{String}: Optionally pass the locale to use, otherwise the default locale is used.returns
{Object}: Returns the this.questions
object, for chainingExample
.askapp.question('beverage', 'What is your favorite beverage?');
Â
app.question('beverage', {
  type: 'input',
  message: 'What is your favorite beverage?'
});
Â
app.question({
  name: 'beverage'
  type: 'input',
  message: 'What is your favorite beverage?'
});
Ask one or more questions, with the given options
and callback.
Params
queue
{String|Array}: Name or array of question names.options
{Object|Function}: Question options or callback functioncallback
{Function}: callback functionExample
About Related projectsapp.ask(function(err, answers) {
  console.log(answers);
});
Â
app.ask(['name', 'description'], function(err, answers) {
  console.log(answers);
});
choices
question types: checkbox⦠more | homepagePull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs(This document was generated by verb-generate-readme (a verb generator), please don't edit the readme directly. Any changes to the readme must be made in .verb.md.)
To generate the readme and API documentation with verb:
Running tests$ npm install -g verb verb-generate-readme && verb
Install dev dependencies:
Author$ npm install -d && npm test
Jon Schlinkert
LicenseCopyright © 2016, Jon Schlinkert. Released under the MIT license.
This file was generated by verb-generate-readme, v0.1.31, on October 01, 2016.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4