Created
February 15, 2016 18:11
-
-
Save jweinst1/3c62ed376e2b189fec38 to your computer and use it in GitHub Desktop.
basic program to read lines and emit a response
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var readline = require('readline'), | |
rl = readline.createInterface(process.stdin, process.stdout); | |
rl.setPrompt('TTT> '); | |
rl.prompt(); | |
rl.on('line', function(line) { | |
switch(line.trim()) { | |
case 'hello': | |
console.log('world!'); | |
break; | |
case 'close': | |
process.exit(0); | |
default: | |
console.log('Say what? I might have heard `' + line.trim() + '`'); | |
break; | |
} | |
rl.prompt(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment