summaryrefslogtreecommitdiff
path: root/src/cmd/cls.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/cls.zig')
-rw-r--r--src/cmd/cls.zig12
1 files changed, 8 insertions, 4 deletions
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 };
}