PIPE: Add pipe support for passing data into and out of terminal commands (#2395)

This commit is contained in:
Michael Ficocelli
2026-02-22 12:18:23 -07:00
committed by GitHub
parent 4a22e16058
commit 92b8b58588
68 changed files with 2430 additions and 480 deletions
+6 -4
View File
@@ -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);
}