-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
32 lines (27 loc) · 840 Bytes
/
main.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
import args from "./src/args.js";
import logger from "./src/logger.js";
import help from "./src/commands/help.js";
import version from "./src/commands/version.js";
import sendRequest from "./src/commands/send-request.js";
const commands = [
{ name: "help", engine: help },
{ name: "version", engine: version },
{ name: "send-request", engine: sendRequest },
];
logger.debug("Args provided:");
logger.debug(args);
for (const command of commands) {
logger.debug(`Trying to match with command ${command.name}`);
if (command.engine.match(args)) {
logger.debug(`Match found for command ${command.name}. Executing...`);
try {
await command.engine.execute(args);
} catch (err) {
logger.error(err.message);
logger.debug(err);
}
Deno.exit(0);
} else {
logger.debug("No match found");
}
}