From 4dd206a5a3a32e23e05c0842ce4db7a108de4d5f Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Thu, 14 Aug 2025 17:50:42 +0200 Subject: Refactor shared eval function parameters into a CommandContext struct. --- src/cmd/pipe.zig | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/cmd/pipe.zig') diff --git a/src/cmd/pipe.zig b/src/cmd/pipe.zig index 4f079cb..f97561a 100644 --- a/src/cmd/pipe.zig +++ b/src/cmd/pipe.zig @@ -4,6 +4,7 @@ const print = std.debug.print; const types = @import("./lib/types.zig"); const CommandStatus = types.CommandStatus; +const CommandContext = types.CommandContext; const OutputCapture = types.OutputCapture; const InputSource = types.InputSource; @@ -17,8 +18,11 @@ pub const PipeCommand = struct { left: *Command, right: *Command, - pub fn eval(pipe: PipeCommand, allocator: Allocator, output_capture: ?*OutputCapture, input_source: ?*InputSource, executeCommandWithOutput: ExecuteCommandFn) !CommandStatus { - _ = input_source; // Pipe handles its own input flow + pub fn eval(pipe: PipeCommand, ctx: CommandContext) !CommandStatus { + // Cast the execute function back to its proper type + const executeCommandWithOutput: ExecuteCommandFn = @ptrCast(@alignCast(ctx.execute_command.?)); + const allocator = ctx.allocator; + const output_capture = ctx.output_capture; // Create output capture for the left command var left_output = OutputCapture.init(allocator); -- cgit v1.2.1