2021-09-16 01:50:44 +02:00
|
|
|
import { ITerminal } from "../ITerminal";
|
2021-09-17 08:58:02 +02:00
|
|
|
import { IRouter } from "../../ui/Router";
|
2021-09-16 01:50:44 +02:00
|
|
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
|
|
|
import { BaseServer } from "../../Server/BaseServer";
|
|
|
|
import { TerminalHelpText, HelpTexts } from "../HelpText";
|
|
|
|
|
|
|
|
export function help(
|
|
|
|
terminal: ITerminal,
|
2021-09-17 08:58:02 +02:00
|
|
|
router: IRouter,
|
2021-09-16 01:50:44 +02:00
|
|
|
player: IPlayer,
|
|
|
|
server: BaseServer,
|
2021-12-03 20:44:32 +01:00
|
|
|
args: (string | number | boolean)[],
|
2021-09-16 01:50:44 +02:00
|
|
|
): void {
|
|
|
|
if (args.length !== 0 && args.length !== 1) {
|
|
|
|
terminal.error("Incorrect usage of help command. Usage: help");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (args.length === 0) {
|
2021-09-16 09:13:06 +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) {
|
|
|
|
terminal.error("No help topics match '" + cmd + "'");
|
|
|
|
return;
|
|
|
|
}
|
2021-09-16 09:13:06 +02:00
|
|
|
txt.forEach((t) => terminal.print(t));
|
2021-09-16 01:50:44 +02:00
|
|
|
}
|
|
|
|
}
|