You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cli-qa

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-qa

Command-line Questions & Answers

2.2.0
Source
npm
Version published
Weekly downloads
14
-22.22%
Maintainers
1
Weekly downloads
 
Created
Source

cli-qa

Command-line Questions & Answers. Supports color formatting, lists, yes/no confirmations.

Install

$ npm install cli-qa

Usage

var NewQA = require('cli-qa')

var QA = NewQA()
QA.ask("{white}Name:{reset}")
QA.ask({ title: "Username:", default: process.env.USER })
QA.ask({ key: "email", title: "E-Mail:", expect: { email: true } })
QA.ask({ title: "{red}Favorite foods:{reset}", list: 3 })
QA.ask({ key: "books", title: "{white}Favorite books:{reset}", list: true })
QA.ask({ title: "{yellow}Favorite {green}Fruits{reset}:", commaList: true })
QA.ask({ key: 'thatsAll', title: "{yellow}That's all, {name}? (yes/no){reset}", yesno: true })

QA.start(function (answers) {
  console.log(answers)
  // => {
  //      "name": "Azer",
  //      "username": "ak",
  //      "email": "azer@roadbeats.com",
  //      "foods": ["falafel", "babi guling", "kebab"],
  //      "favoriteBooks": ["snow", "white castle"],
  //      "thoughts": "let's go somewhere!",
  //      "thatsAll": true
  //    }
})

Reference

The list of available options for each question:

key

The key that will be used in the answers object. If not specified, it'll be auto-generated

title

Title of the question. styling accepted.

list

If a numeric value is passed, user will be prompted to enter a list with expected number of lines. If true passed, the list input won't be limited.

commaList

Specify "true" if a comma-separated list is expected as an answer

yesno

Yes/no question? true/false

default

Default value if answer is empty.

expect

Specify requirements for validating the user input.

validate

Async validation function. See tests for example.

Keywords

io

FAQs

Package last updated on 21 Jan 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