Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cli-interact

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-interact

Simple helper tools for interacting synchronously with user at command line

  • 0.1.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.8K
decreased by-21.29%
Maintainers
1
Weekly downloads
 
Created
Source

cli-interact

Simple helper tools for interacting synchronously with user at command line. The interface is used with process.stdin and process.stdout in order to accept user input.

Example

var	query = require('cli-interact').getYesNo;
var answer = query('Is it true');
console.log('you answered:', answer);
$ node examples/getYesNoNone.js
Is it true (y/n)? j
Is it true (y/n)? y
you answered: true

Installation

npm install cli-interact

Usage

Queries

Presently, there are three queries:

getChar gets a single character from some set of allowed characters.

getIPversion gets a single character, either '4' or '6'.

getYesNo prompts for 'y' or 'n', returns true/false. Can be configured to allow no response (returns undefined).

And a passthorugh question to access the underlying readlineSync.question method.

Notes

Uses the readline-sync module. See it for more information.

Platforms

The your Node and OS may not support interactively reading from stdin. The stdin interfaces are different by platforms. If in those platforms, an error is thrown by readlineSync.

try {
  answer = readlineSync.question('What is your favorite food? :');
} catch (e) {
  console.error(e);
  process.exit(1);
}

Release History

  • 2014-11-14 v0.1.0 Initial release.

Keywords

FAQs

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