-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
41 lines (38 loc) · 887 Bytes
/
index.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
const {
logVoro,
log,
logOptions,
sleep,
getUserInput,
} = require("./src/utils.js");
const { menus, paths } = require("./config.json");
const path = require("path");
const init = async () => {
logVoro();
logOptions(menus);
log("", "info");
let answer = await getUserInput("Selection: ");
await handler(parseInt(answer));
};
const handler = async (selection) => {
if (isNaN(selection) || selection > menus.length || selection < 1) {
log(`[X] Invalid Selection`, "error");
}
if (menus.length === selection) {
log("[>] Exiting CLI...", "error");
process.exit();
} else {
switch (selection) {
default:
log(`[>] Loading '${menus[selection - 1]}'`, "info");
let { run } = require(path.join(
__dirname,
"src",
paths[selection - 1]
));
run();
break;
}
}
};
init();