Skip to content

kaiwood/getstring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

getstring

A very simple library to prompt for user input on the command line.

Installation

npm install getstring

Usage

var gets = require("getstring");

gets("Who are you?", function (answer) {
    console.log("You are: " + answer);
};

An optional, second function argument to validate the input is possible:

 var gets = require("./index");
 
 function validateNumber(input) {
   if (isNaN(parseInt(input))) {
     console.log("Not a number");
     return false;
   } else {
     return true;
   }
 };
 
 gets("A number please", validateNumber, function(answer){
   console.log(answer)
   process.exit();
 });

Release History

  • 0.2.1 Add syntax highlighting to README.md
  • 0.2.0 Add optional validation parameter
  • 0.1.0 Initial release

About

A very simple node library to prompt for user input on the command line.

Resources

License

Stars

Watchers

Forks

Packages

No packages published