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

20 lines
603 B
TypeScript
Raw Normal View History

2022-09-06 15:07:12 +02:00
import { Terminal } from "../../Terminal";
import { Player } from "@player";
2022-09-06 15:07:12 +02:00
export function history(args: (string | number | boolean)[]): void {
if (args.length === 0) {
2022-09-06 15:07:12 +02:00
Terminal.commandHistory.forEach((command, index) => {
Terminal.print(`${index.toString().padStart(2)} ${command}`);
});
return;
}
const arg = args[0] + "";
if (arg === "-c" || arg === "--clear") {
2022-09-06 15:07:12 +02:00
Player.terminalCommandHistory = [];
Terminal.commandHistory = [];
Terminal.commandHistoryIndex = 1;
} else {
2022-09-06 15:07:12 +02:00
Terminal.error("Incorrect usage of history command. usage: history [-c]");
}
}