2022-09-06 15:07:12 +02:00
|
|
|
import { Terminal } from "../../Terminal";
|
2021-09-16 01:50:44 +02:00
|
|
|
import { TerminalHelpText, HelpTexts } from "../HelpText";
|
|
|
|
|
2022-09-06 15:07:12 +02:00
|
|
|
export function help(args: (string | number | boolean)[]): void {
|
2021-09-16 01:50:44 +02:00
|
|
|
if (args.length !== 0 && args.length !== 1) {
|
2022-09-06 15:07:12 +02:00
|
|
|
Terminal.error("Incorrect usage of help command. Usage: help");
|
2021-09-16 01:50:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (args.length === 0) {
|
2022-09-06 15:07:12 +02:00
|
|
|
TerminalHelpText.forEach((line) => Terminal.print(line));
|
2021-09-16 01:50:44 +02:00
|
|
|
} else {
|
2021-12-03 20:44:32 +01:00
|
|
|
const cmd = args[0] + "";
|
2021-09-16 01:50:44 +02:00
|
|
|
const txt = HelpTexts[cmd];
|
|
|
|
if (txt == null) {
|
2022-09-06 15:07:12 +02:00
|
|
|
Terminal.error("No help topics match '" + cmd + "'");
|
2021-09-16 01:50:44 +02:00
|
|
|
return;
|
|
|
|
}
|
2022-09-06 15:07:12 +02:00
|
|
|
txt.forEach((t) => Terminal.print(t));
|
2021-09-16 01:50:44 +02:00
|
|
|
}
|
|
|
|
}
|