-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
54 lines (48 loc) · 1.1 KB
/
main.js
File metadata and controls
54 lines (48 loc) · 1.1 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
const { get, create, update, remove } = require('./methods.js');
const readlineSync = require('readline-sync');
const readline = require('readline');
function pauseExecution() {
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
return new Promise((resolve) => {
rl.question('Press Enter to continue...', () => {
console.clear();
rl.close();
resolve();
});
});
}
async function main() {
do {
var key = readlineSync.questionInt('1. Get\n2. Create\n3. Edit\n4. Remove\n5. Salir\n Opcion:');
switch (key) {
case 1:
get();
await pauseExecution();
break;
case 2:
create();
await pauseExecution();
break;
case 3:
update();
await pauseExecution();
break;
case 4:
remove();
await pauseExecution();
break;
case 5:
await pauseExecution();
console.log("Adios");
key = -1;
break;
default:
console.log("Opcion no valida");
break;
}
} while (key != -1);
}
main();