mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-29 12:27:07 +02:00
PIPE: Add pipe support for passing data into and out of terminal commands (#2395)
This commit is contained in:
committed by
GitHub
parent
4a22e16058
commit
92b8b58588
@@ -1,8 +1,10 @@
|
||||
import { Terminal } from "../../Terminal";
|
||||
import { StdIO } from "../StdIO/StdIO";
|
||||
import { BaseServer } from "../../Server/BaseServer";
|
||||
|
||||
export function expr(args: (string | number | boolean)[]): void {
|
||||
export function expr(args: (string | number | boolean)[], server: BaseServer, stdIO: StdIO): void {
|
||||
if (args.length === 0) {
|
||||
Terminal.error("Incorrect usage of expr command. Usage: expr [math expression]");
|
||||
Terminal.error("Incorrect usage of expr command. Usage: expr [math expression]", stdIO);
|
||||
return;
|
||||
}
|
||||
const expr = args.join("");
|
||||
@@ -13,8 +15,8 @@ export function expr(args: (string | number | boolean)[]): void {
|
||||
try {
|
||||
result = String(eval?.(sanitizedExpr));
|
||||
} catch (e) {
|
||||
Terminal.error(`Could not evaluate expression: ${sanitizedExpr}. Error: ${e}.`);
|
||||
Terminal.error(`Could not evaluate expression: ${sanitizedExpr}. Error: ${e}.`, stdIO);
|
||||
return;
|
||||
}
|
||||
Terminal.print(result);
|
||||
Terminal.print(result, stdIO);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user