const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: ‘请输入> ‘
});
rl.prompt();
rl.on(‘line‘, function (line){
switch (line.trim()) {
case ‘hello‘:
console.log(‘world!‘);
break;
default:
console.log(‘你输入的是:‘,line.trim());
break;
}
rl.prompt();
}).on(‘close‘, function(){
console.log(‘再见!‘);
process.exit(0);
});