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/rename.zig | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'src/cmd/rename.zig') diff --git a/src/cmd/rename.zig b/src/cmd/rename.zig index 386e0f7..58a5702 100644 --- a/src/cmd/rename.zig +++ b/src/cmd/rename.zig @@ -1,6 +1,5 @@ const std = @import("std"); const Allocator = std.mem.Allocator; -const print = std.debug.print; const syntax = @import("../syntax.zig"); const FileSpec = syntax.FileSpec; @@ -17,11 +16,8 @@ pub const Rename = struct { const from_path = switch (rename.from) { .Con, .Lpt1, .Lpt2, .Lpt3, .Prn => { const error_msg = "Cannot rename device\n"; - if (ctx.output_capture) |capture| { - try capture.write(error_msg); - } else { - print("{s}", .{error_msg}); - } + var writer = ctx.output_writer; + try writer.write(error_msg); return CommandStatus{ .Code = 1 }; }, .Path => |path| path, @@ -30,11 +26,8 @@ pub const Rename = struct { const to_path = switch (rename.to) { .Con, .Lpt1, .Lpt2, .Lpt3, .Prn => { const error_msg = "Cannot rename to device\n"; - if (ctx.output_capture) |capture| { - try capture.write(error_msg); - } else { - print("{s}", .{error_msg}); - } + var writer = ctx.output_writer; + try writer.write(error_msg); return CommandStatus{ .Code = 1 }; }, .Path => |path| path, @@ -48,11 +41,8 @@ pub const Rename = struct { error.RenameAcrossMountPoints => "Cannot rename across different drives\n", else => "Cannot rename file\n", }; - if (ctx.output_capture) |capture| { - try capture.write(error_msg); - } else { - print("{s}", .{error_msg}); - } + var writer = ctx.output_writer; + try writer.write(error_msg); return CommandStatus{ .Code = 1 }; }; -- cgit v1.2.1