From 438d69c8381676c5ee9918dca88619a068df85b9 Mon Sep 17 00:00:00 2001 From: memetrollsXD Date: Mon, 1 Aug 2022 13:41:37 +0200 Subject: [PATCH] Basic help command --- src/commands/alias.json | 7 ++++++- src/commands/exit.ts | 2 +- src/commands/help.ts | 16 ++++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 src/commands/help.ts diff --git a/src/commands/alias.json b/src/commands/alias.json index fca2cbc..621a901 100644 --- a/src/commands/alias.json +++ b/src/commands/alias.json @@ -1,3 +1,8 @@ { - "close": "exit" + "close": "exit", + "stop": "exit", + "t": "target", + "acc": "account", + "d": "debug", + "?": "help" } \ No newline at end of file diff --git a/src/commands/exit.ts b/src/commands/exit.ts index 1bd8647..6989b36 100644 --- a/src/commands/exit.ts +++ b/src/commands/exit.ts @@ -4,5 +4,5 @@ const c = new Logger("/exit", "blue"); export default async function handle(command: Command) { c.log("Good riddance!"); - process.exit(1); + process.exit(0); } \ No newline at end of file diff --git a/src/commands/help.ts b/src/commands/help.ts new file mode 100644 index 0000000..b6d4631 --- /dev/null +++ b/src/commands/help.ts @@ -0,0 +1,16 @@ +import Logger from "../util/Logger"; +import { Command } from "./Interface"; +import fs from 'fs'; +const c = new Logger("/help", "blue"); + +export default async function handle(command: Command) { + const cmds = fs.readdirSync(__dirname); + c.log(`${cmds.length} commands available:`) + + cmds.forEach(cmd => { + if (cmd.endsWith(".ts")) { + const cmdName = cmd.replace(/.ts/gm, ""); + if (cmdName !== "Interface") c.trail(cmdName); + } + }) +} \ No newline at end of file