mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 01:53:48 +01:00
tail is smarter
This commit is contained in:
parent
6661473adc
commit
2b13b5329f
@ -53,6 +53,7 @@ import { WorkerScriptStartStopEventEmitter } from "./Netscript/WorkerScriptStart
|
|||||||
import { Player } from "./Player";
|
import { Player } from "./Player";
|
||||||
import { hackWorldDaemon } from "./RedPill";
|
import { hackWorldDaemon } from "./RedPill";
|
||||||
import { RunningScript } from "./Script/RunningScript";
|
import { RunningScript } from "./Script/RunningScript";
|
||||||
|
import { compareArrays } from "../utils/helpers/compareArrays";
|
||||||
import { getRamUsageFromRunningScript } from "./Script/RunningScriptHelpers";
|
import { getRamUsageFromRunningScript } from "./Script/RunningScriptHelpers";
|
||||||
import {
|
import {
|
||||||
getCurrentEditor,
|
getCurrentEditor,
|
||||||
@ -1422,13 +1423,46 @@ let Terminal = {
|
|||||||
args.push(commandArray[i]);
|
args.push(commandArray[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the script exists on this machine
|
// go over all the running scripts. If there's a perfect
|
||||||
const runningScript = findRunningScript(scriptName, args, s);
|
// match, use it!
|
||||||
if (runningScript == null) {
|
for (var i = 0; i < s.runningScripts.length; ++i) {
|
||||||
postError("No such script exists");
|
if (s.runningScripts[i].filename === scriptName &&
|
||||||
|
compareArrays(s.runningScripts[i].args, args)) {
|
||||||
|
logBoxCreate(s.runningScripts[i]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logBoxCreate(runningScript);
|
}
|
||||||
|
|
||||||
|
// Find all scripts that are potential candidates.
|
||||||
|
const candidates = [];
|
||||||
|
for (var i = 0; i < s.runningScripts.length; ++i) {
|
||||||
|
// only scripts that have more arguments (equal arguments is already caught)
|
||||||
|
if(s.runningScripts[i].args.length < args.length) continue;
|
||||||
|
// make a smaller copy of the args.
|
||||||
|
const args2 = s.runningScripts[i].args.slice(0, args.length);
|
||||||
|
if (s.runningScripts[i].filename === scriptName &&
|
||||||
|
compareArrays(args2, args)) {
|
||||||
|
candidates.push(s.runningScripts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there's only 1 possible choice, use that.
|
||||||
|
if(candidates.length === 1) {
|
||||||
|
logBoxCreate(candidates[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// otherwise lists all possible conflicting choices.
|
||||||
|
if(candidates.length > 1) {
|
||||||
|
postError("Found several potential candidates:");
|
||||||
|
for(const candidate of candidates)
|
||||||
|
postError(`${candidate.filename} ${candidate.args.join(' ')}`);
|
||||||
|
postError("Script arguments need to be specified.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there's no candidate then we just don't know.
|
||||||
|
postError("No such script exists.");
|
||||||
} else {
|
} else {
|
||||||
const runningScript = findRunningScriptByPid(commandArray[1], Player.getCurrentServer());
|
const runningScript = findRunningScriptByPid(commandArray[1], Player.getCurrentServer());
|
||||||
if (runningScript == null) {
|
if (runningScript == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user