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
+17 -3
View File
@@ -19,6 +19,10 @@ import { ScriptKey, scriptKey } from "../utils/helpers/scriptKey";
import type { LogBoxProperties } from "../ui/React/LogBoxManager";
import { StdIO } from "../Terminal/StdIO/StdIO";
import { IOStream } from "../Terminal/StdIO/IOStream";
import { getTerminalStdIO } from "../Terminal/StdIO/RedirectIO";
export class RunningScript {
// Script arguments
args: ScriptArg[] = [];
@@ -70,9 +74,17 @@ export class RunningScript {
// Cached key for ByArgs lookups. Will be overwritten by a correct ScriptKey in fromJSON or constructor
scriptKey = "" as ScriptKey;
stdin: IOStream | null = null;
// Access to properties of the tail window. Can be used to get/set size, position, etc.
tailProps = null as LogBoxProperties | null;
// Configuration for piping the script's tail output
tailStdOut: StdIO | null = null;
// Configuration for piping the script's terminal output
terminalStdOut: StdIO = getTerminalStdIO(null);
// The title, as shown in the script's log box. Defaults to the name + args,
// but can be changed by the user. If it is set to a React element (only by the user),
// that will not be persisted, and will be restored to default on load.
@@ -111,14 +123,16 @@ export class RunningScript {
this.logs.push(logEntry);
this.logUpd = true;
this.tailStdOut?.write?.(logEntry);
}
displayLog(): void {
displayLog(stdIO: StdIO): void {
for (const log of this.logs) {
if (typeof log === "string") {
Terminal.print(log);
Terminal.print(log, stdIO);
} else {
Terminal.printRaw(log);
Terminal.printRaw(log, stdIO);
}
}
}