-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
89 lines (68 loc) · 1.83 KB
/
Copy pathmain.js
File metadata and controls
89 lines (68 loc) · 1.83 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const readline = require('readline');
const {log, biglog, errorlog, colorize} = require("./out");
const cmds = require("./cmds");
//Mensaje inicial
biglog('CORE Quiz', 'green');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
prompt: colorize("quiz >", 'blue'),
completer: (line) => {
const completions = 'h help add delete edit list test p play credits q quit'.split(' ');
const hits = completions.filter((c) => c.startsWith(line));
// show all completions if none found
return [hits.length ? hits : completions, line];
}
});
rl.prompt();
rl.on('line', (line) => {
let args = line.split(" ");
let cmd = args[0].toLowerCase().trim();
switch (cmd) {
case '':
rl.prompt();
break;
case 'h':
case 'help':
cmds.helpCommand(rl);
break;
case 'quit':
case 'q':
cmds.quitCommand(rl);
break;
case 'add':
cmds.addCommand(rl);
break;
case 'list':
cmds.listCommand(rl);
break;
case 'test':
cmds.testCommand(rl,args[1]);
break;
case 'play':
case 'p':
cmds.playCommand(rl);
break;
case 'delete' :
cmds.deleteCommand(rl, args[1]);
break;
case 'edit' :
cmds.editCommand(rl,args[1]);
break;
case 'credits' :
cmds.creditsCommand(rl);
break;
case 'show' :
cmds.showCommand(rl,args[1]);
break;
default:
log(`Comando desconocido: '${colorize(cmd, 'red')}'`);
log(`Use ${colorize('help', 'green')} para ver todos los comandos disponibles"`);
rl.prompt();
break;
}
}).on('close', () => {
log('Adios!');
process.exit(0);
});
//Minuto del video 47 ya he implementado lista