mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 17:43:48 +01:00
Merge pull request #2061 from 65-7a/allow-cat-on-scripts-patch
Allow cat to work on scripts
This commit is contained in:
commit
ab0ed5d6a4
@ -4,6 +4,7 @@ import { IPlayer } from "../../PersonObjects/IPlayer";
|
|||||||
import { BaseServer } from "../../Server/BaseServer";
|
import { BaseServer } from "../../Server/BaseServer";
|
||||||
import { showMessage } from "../../Message/MessageHelpers";
|
import { showMessage } from "../../Message/MessageHelpers";
|
||||||
import { showLiterature } from "../../Literature/LiteratureHelpers";
|
import { showLiterature } from "../../Literature/LiteratureHelpers";
|
||||||
|
import { dialogBoxCreate } from "../../ui/React/DialogBox";
|
||||||
|
|
||||||
export function cat(
|
export function cat(
|
||||||
terminal: ITerminal,
|
terminal: ITerminal,
|
||||||
@ -18,9 +19,9 @@ export function cat(
|
|||||||
}
|
}
|
||||||
const relative_filename = args[0] + "";
|
const relative_filename = args[0] + "";
|
||||||
const filename = terminal.getFilepath(relative_filename);
|
const filename = terminal.getFilepath(relative_filename);
|
||||||
if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) {
|
if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt") && !filename.endsWith(".script") && !filename.endsWith(".js") && !filename.endsWith(".ns")) {
|
||||||
terminal.error(
|
terminal.error(
|
||||||
"Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)",
|
"Only .msg, .txt, .lit, .script, .js, and .ns files are viewable with cat (filename must end with .msg, .txt, .lit, .script, .js, or .ns)",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -45,6 +46,12 @@ export function cat(
|
|||||||
txt.show();
|
txt.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (filename.endsWith(".script") || filename.endsWith(".js") || filename.endsWith(".ns")) {
|
||||||
|
const script = terminal.getScript(player, relative_filename);
|
||||||
|
if (script != null) {
|
||||||
|
dialogBoxCreate(`${script.filename}<br /><br />${script.code}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
terminal.error(`No such file ${filename}`);
|
terminal.error(`No such file ${filename}`);
|
||||||
|
@ -353,6 +353,7 @@ export async function determineAllPossibilitiesForTabCompletion(
|
|||||||
addAllLitFiles();
|
addAllLitFiles();
|
||||||
addAllTextFiles();
|
addAllTextFiles();
|
||||||
addAllDirectories();
|
addAllDirectories();
|
||||||
|
addAllScripts();
|
||||||
|
|
||||||
return allPos;
|
return allPos;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user