mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-10-23 10:13:13 +02:00
28 lines
808 B
TypeScript
28 lines
808 B
TypeScript
|
import { ITerminal } from "../ITerminal";
|
||
|
import { IRouter } from "../../ui/Router";
|
||
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||
|
import { BaseServer } from "../../Server/BaseServer";
|
||
|
|
||
|
export function history(
|
||
|
terminal: ITerminal,
|
||
|
router: IRouter,
|
||
|
player: IPlayer,
|
||
|
server: BaseServer,
|
||
|
args: (string | number | boolean)[],
|
||
|
): void {
|
||
|
if (args.length === 0) {
|
||
|
terminal.commandHistory.forEach((command, index) => {
|
||
|
terminal.print(`${index.toString().padStart(2)} ${command}`);
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
const arg = args[0] + "";
|
||
|
if (arg === "-c" || arg === "--clear") {
|
||
|
player.terminalCommandHistory = [];
|
||
|
terminal.commandHistory = [];
|
||
|
terminal.commandHistoryIndex = 1;
|
||
|
} else {
|
||
|
terminal.error("Incorrect usage of history command. usage: history [-c]");
|
||
|
}
|
||
|
}
|