bitburner-src/src/Terminal/commands/help.ts

30 lines
795 B
TypeScript
Raw Normal View History

2021-09-16 01:50:44 +02:00
import { ITerminal } from "../ITerminal";
import { IEngine } from "../../IEngine";
import { IPlayer } from "../../PersonObjects/IPlayer";
import { BaseServer } from "../../Server/BaseServer";
import { TerminalHelpText, HelpTexts } from "../HelpText";
export function help(
terminal: ITerminal,
engine: IEngine,
player: IPlayer,
server: BaseServer,
args: (string | number)[],
): void {
if (args.length !== 0 && args.length !== 1) {
terminal.error("Incorrect usage of help command. Usage: help");
return;
}
if (args.length === 0) {
terminal.print(TerminalHelpText);
} else {
const cmd = args[0];
const txt = HelpTexts[cmd];
if (txt == null) {
terminal.error("No help topics match '" + cmd + "'");
return;
}
terminal.print(txt);
}
}