cli support

This commit is contained in:
2022-11-24 20:15:36 +01:00
parent 62aa05031f
commit cd60d7dabc
7 changed files with 316 additions and 4 deletions

68
src/cli/index.ts Normal file
View File

@@ -0,0 +1,68 @@
import * as readline from "node:readline/promises";
import { stdin as input, stdout as output } from "node:process";
import pack from "../../package.json";
import { Console } from "node:console";
import moment from "moment";
import guild from "./guild";
import global from "./global";
const console = new Console(process.stdout);
const startupTime = new Date();
const rl = readline.createInterface(input, output);
rl.on("line", async (msg) => {
const [command, ...args] = msg.split(" ");
if (!command) return;
switch (command.toLowerCase()) {
case "version": {
console.log(`Channel filter V${pack.version} by AstroGD®`);
break;
}
case "uptime": {
console.log(`Application is running for ${moment(startupTime).fromNow(true)}`);
break;
}
case "clear": {
console.clear();
break;
}
case "guild": {
await guild(args);
break;
}
case "help": {
printHelp();
break;
}
case "global": {
await global(args);
break;
}
default: {
console.log(`Unknown command. Try "help" for help`);
break;
}
}
rl.prompt();
});
function printHelp() {
console.log(`Commands:
version
uptime
guild
global
help
clear`);
}