Created
April 21, 2020 08:24
-
-
Save Tonyce/bdb7a3473063dbfdd5a9c3027f8e0e86 to your computer and use it in GitHub Desktop.
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
var readline = require('readline'), | |
rl = readline.createInterface(process.stdin, process.stdout); | |
rl.setPrompt('OHAI> '); | |
rl.prompt(); | |
rl.on('line', function(line) { | |
switch(line.trim()) { | |
case 'exit': | |
rl.close(); | |
break; | |
case 'hello': | |
console.log('world!'); | |
break; | |
default: | |
console.log('Say what? I might have heard `' + line.trim() + '`'); | |
break; | |
} | |
rl.prompt(); | |
}).on('close', function() { | |
console.log('Have a great day!'); | |
process.exit(0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment