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 - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

examples/getChoiceByChar.js

39

index.js

@@ -33,2 +33,38 @@ //==============================

function getChoiceByChar (title, choices, flagAllowNoAnswer) {
var answer;
var i;
var numChoices = choices.length;
var parts = ['Select ', title, ' ('];
var queryText;
var str;
var value;
for (i = 1; i <= numChoices; i += 1) { // display 1 based to user
parts.push(i);
parts.push('=');
parts.push(choices[i - 1]); // choices array is 0-based
parts.push('; ');
}
parts.pop(); // get rid of trailing ';'
parts.push(') ?');
queryText = parts.join('');
while (true) {
answer = readlineSync.question(queryText);
if (answer === "\u0003") {
// Ctl-C
process.exit();
} else if (flagAllowNoAnswer && (answer === '')) {
return answer;
} else {
value = parseInt(answer, 10);
if ((value >= 1) && (value <= numChoices)) {
return choices[value - 1]; // user input is 1-based; choices array is 0-based
}
}
}
}
function getInteger (promptText) { // convenience method

@@ -71,3 +107,3 @@ return getNumber(promptText, true);

var answer;
var queryText = title + ' (y/n)? '
var queryText = title + ' (y/n)? ';
while (true) {

@@ -105,2 +141,3 @@ answer = readlineSync.question(queryText);

getChar : getChar
, getChoiceByChar : getChoiceByChar
, getInteger : getInteger

@@ -107,0 +144,0 @@ , getIPversion : getIPversion

2

package.json
{
"name": "cli-interact",
"version": "0.1.5",
"version": "0.1.6",
"title": "cli interact",

@@ -5,0 +5,0 @@ "description": "Simple helper tools for interacting synchronously with user at command line",

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