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/remove.zig | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/cmd/remove.zig') diff --git a/src/cmd/remove.zig b/src/cmd/remove.zig index 7b85f1d..e7d2688 100644 --- a/src/cmd/remove.zig +++ b/src/cmd/remove.zig @@ -4,15 +4,14 @@ const print = std.debug.print; const types = @import("./lib/types.zig"); const CommandStatus = types.CommandStatus; -const OutputCapture = types.OutputCapture; -const InputSource = types.InputSource; +const CommandContext = types.CommandContext; pub const Remove = struct { path: []const u8, - pub fn eval(remove: Remove, allocator: Allocator, output_capture: ?*OutputCapture, input_source: ?*InputSource) !CommandStatus { - _ = allocator; - _ = input_source; + pub fn eval(remove: Remove, ctx: CommandContext) !CommandStatus { + _ = ctx.allocator; + _ = ctx.input_source; const file_path = remove.path; @@ -20,7 +19,7 @@ pub const Remove = struct { if (std.mem.indexOf(u8, file_path, "*") != null or std.mem.indexOf(u8, file_path, "?") != null) { // Simple wildcard deletion - just show error for now const error_msg = "Wildcard deletion not yet implemented\n"; - if (output_capture) |capture| { + if (ctx.output_capture) |capture| { try capture.write(error_msg); } else { print("{s}", .{error_msg}); @@ -36,7 +35,7 @@ pub const Remove = struct { error.IsDir => "Access denied - cannot delete directory\n", else => "Cannot delete file\n", }; - if (output_capture) |capture| { + if (ctx.output_capture) |capture| { try capture.write(error_msg); } else { print("{s}", .{error_msg}); -- cgit v1.2.1