-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadline.js
50 lines (44 loc) · 1.17 KB
/
readline.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// var readline = require(‘readline’);
// var completer = function (userInput) {
// var completions = '.help .error .exit .quit .q'.split(' ')
// var hits = completions.filter(function(c) {
// if (c.indexOf(userInput) == 0) {
// // console.log('bang! ' + c);
// return c;
// }
// });
// return [hits && hits.length ? hits : completions, userInput];
// }
// var rl = readline.createInterface({
// input:process.stdin,
// output:process.stdout,
// completer: completer
// });
var params = [];
var rl = readline.createInterface({
input:process.stdin,
output:process.stdout,
// completer: completer
});
var prefix = 'tpl type> ';
rl.on('line', function (cmd) {
console.log(chalk.red('==> ') + cmd);
params.push(cmd);
if (params.length < 2) {
rl.setPrompt("second>", "second".length);
rl.prompt();
}
else {
console.log(chalk.green(params));
rl.close();
}
//rl.close();
}).on('close', function () {
console.log(chalk.red("see you "));
});
rl.setPrompt(prefix, prefix.length);
rl.prompt();
// rl.question("give me your page id?\n",function(answer){
// console.log(answer);
// //rl.close();
// });