Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kapiljhajhria/4a18809318cca1725169a0fd6f984078 to your computer and use it in GitHub Desktop.
Save kapiljhajhria/4a18809318cca1725169a0fd6f984078 to your computer and use it in GitHub Desktop.
Simple interactive node.js script to have users continuously enter input.
// Taken from:
// http://stackoverflow.com/questions/24464404/how-to-readline-infinitely-in-node-js
const readline = require('readline');
var log = console.log;
var rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
function searchPrompt() {
rl.question('cmd> ', input => {
if( input == 'exit' )
return rl.close();
log('You entered: ', input);
searchPrompt();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment