CLI: Add "hidden" mkdir command (#2646)

This commit is contained in:
catloversg
2026-04-11 05:45:51 +07:00
committed by GitHub
parent 5cb0d559df
commit 09e46d757b
3 changed files with 17 additions and 5 deletions

View File

@@ -78,6 +78,7 @@ import { commitHash } from "../utils/helpers/commitHash";
import { apr1 } from "./commands/apr1";
import { changelog } from "./commands/changelog";
import { clear } from "./commands/clear";
import { mkdir } from "./commands/mkdir";
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
import { Engine } from "../engine";
import { Directory, resolveDirectory, root } from "../Paths/Directory";
@@ -134,8 +135,12 @@ export const TerminalCommands: Record<string, (args: (string | number | boolean)
vim: vim,
weaken: weaken,
wget: wget,
mkdir: mkdir,
};
// "mkdir" is a "hidden" command; i.e., it is not shown in help text or autocomplete.
export const supportedCommands = Object.keys(TerminalCommands).filter((command) => command !== "mkdir");
export class Terminal {
// Flags to determine whether the player is currently running a hack or an analyze
action: TTimer | null = null;
@@ -877,8 +882,7 @@ export class Terminal {
}
function findSimilarCommands(command: string): string[] {
const commands = Object.keys(TerminalCommands);
const offByOneLetter = commands.filter((c) => {
const offByOneLetter = supportedCommands.filter((c) => {
if (c.length !== command.length) return false;
let diff = 0;
for (let i = 0; i < c.length; i++) {
@@ -886,6 +890,6 @@ function findSimilarCommands(command: string): string[] {
}
return diff === 1;
});
const subset = commands.filter((c) => c.includes(command)).sort((a, b) => a.length - b.length);
const subset = supportedCommands.filter((c) => c.includes(command)).sort((a, b) => a.length - b.length);
return Array.from(new Set([...offByOneLetter, ...subset])).slice(0, 3);
}

View File

@@ -0,0 +1,8 @@
import { Terminal } from "../../Terminal";
export function mkdir(): void {
Terminal.error(
"Directories do not exist in the Bitburner filesystem. They are simply part of the file path.\n" +
`For example, with "/foo/bar.txt", there is no actual "/foo" directory.`,
);
}

View File

@@ -11,7 +11,7 @@ import libarg from "arg";
import { getAllDirectories, resolveDirectory, root } from "../Paths/Directory";
import { isLegacyScript, resolveScriptFilePath } from "../Paths/ScriptFilePath";
import { enums } from "../NetscriptFunctions";
import { TerminalCommands } from "./Terminal";
import { supportedCommands } from "./Terminal";
import { Terminal } from "../Terminal";
import { parseUnknownError } from "../utils/ErrorHelper";
import { DarknetServer } from "../Server/DarknetServer";
@@ -84,7 +84,7 @@ export async function getTabCompletionPossibilities(terminalText: string, baseDi
const addAliases = () => addGeneric({ iterable: Aliases.keys() });
const addGlobalAliases = () => addGeneric({ iterable: GlobalAliases.keys() });
const addCommands = () => addGeneric({ iterable: Object.keys(TerminalCommands) });
const addCommands = () => addGeneric({ iterable: supportedCommands });
const addDarkwebItems = () => addGeneric({ iterable: Object.values(DarkWebItems).map((item) => item.program) });
const addServerNames = () =>
addGeneric({