From 9edc1338b92d1ead4c5f2fad8c0516037963f7b6 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sat, 16 Aug 2025 12:50:23 +0200 Subject: Unify output handling. Now every command always uses an OutputWriter instead of conditionally writing directly to stdout using std.debug.print. --- src/cmd/cls.zig | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/cmd/cls.zig') diff --git a/src/cmd/cls.zig b/src/cmd/cls.zig index 4e7b8c6..a017278 100644 --- a/src/cmd/cls.zig +++ b/src/cmd/cls.zig @@ -1,6 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const print = std.debug.print; const types = @import("./lib/types.zig"); const CommandStatus = types.CommandStatus; @@ -10,9 +9,14 @@ pub const Cls = struct { pub fn eval(cls: Cls, ctx: CommandContext) !CommandStatus { _ = cls; - if (ctx.output_capture == null) { - // Clear screen - only works when not redirected - print("\x1B[2J\x1B[H", .{}); + // Clear screen - only works when going to stdout, not when redirected + switch (ctx.output_writer) { + .stdout => |writer| { + try writer.write("\x1B[2J\x1B[H"); + }, + .capture => { + // Do nothing when output is captured/redirected + }, } return CommandStatus{ .Code = 0 }; } -- cgit v1.2.1