mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
BUGFIX: Missing error handler when calling libarg (#1625)
This commit is contained in:
parent
49629d1d28
commit
ac0c9bd7e8
@ -18,10 +18,16 @@ export function runScript(path: ScriptFilePath, commandArgs: (string | number |
|
||||
if (!script) return Terminal.error(`Script ${path} does not exist on this server.`);
|
||||
|
||||
const runArgs = { "--tail": Boolean, "-t": Number, "--ram-override": Number };
|
||||
const flags = libarg(runArgs, {
|
||||
permissive: true,
|
||||
argv: commandArgs,
|
||||
});
|
||||
let flags;
|
||||
try {
|
||||
flags = libarg(runArgs, {
|
||||
permissive: true,
|
||||
argv: commandArgs,
|
||||
});
|
||||
} catch (error) {
|
||||
Terminal.error(`Invalid arguments. ${String(error)}.`);
|
||||
return;
|
||||
}
|
||||
const tailFlag = flags["--tail"] === true;
|
||||
const numThreads = parseFloat(flags["-t"] ?? 1);
|
||||
const ramOverride = flags["--ram-override"] != null ? roundToTwo(parseFloat(flags["--ram-override"])) : null;
|
||||
|
@ -276,10 +276,21 @@ export async function getTabCompletionPossibilities(terminalText: string, baseDi
|
||||
if (!loadedModule || !loadedModule.autocomplete) return; // Doesn't have an autocomplete function.
|
||||
|
||||
const runArgs = { "--tail": Boolean, "-t": Number, "--ram-override": Number };
|
||||
const flags = libarg(runArgs, {
|
||||
permissive: true,
|
||||
argv: command.slice(2),
|
||||
});
|
||||
let flags = {
|
||||
_: [],
|
||||
};
|
||||
try {
|
||||
flags = libarg(runArgs, {
|
||||
permissive: true,
|
||||
argv: command.slice(2),
|
||||
});
|
||||
} catch (error) {
|
||||
/**
|
||||
* This error can only happen when the player specifies "-t" or "--ram-override", then presses [Tab] without
|
||||
* giving a number. We don't need to show an error here.
|
||||
*/
|
||||
console.warn(error);
|
||||
}
|
||||
const flagFunc = Flags(flags._);
|
||||
const autocompleteData: AutocompleteData = {
|
||||
servers: GetAllServers()
|
||||
|
Loading…
Reference in New Issue
Block a user