Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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.

Keywords

FAQs

Package last updated on 31 Oct 2015

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