diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-14 17:50:42 +0200 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2025-08-14 17:53:53 +0200 |
commit | 4dd206a5a3a32e23e05c0842ce4db7a108de4d5f (patch) | |
tree | b83fb3daf371ed53739cefcde1db841df21ca5e4 /src/cmd/mkdir.zig | |
parent | 35a3b9ccfeb9dcd2c88c359108305b7f750622d6 (diff) |
Refactor shared eval function parameters into a CommandContext struct.
Diffstat (limited to 'src/cmd/mkdir.zig')
-rw-r--r-- | src/cmd/mkdir.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/cmd/mkdir.zig b/src/cmd/mkdir.zig index 7009fbc..59ed431 100644 --- a/src/cmd/mkdir.zig +++ b/src/cmd/mkdir.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 Mkdir = struct { path: []const u8, - pub fn eval(mkdir: Mkdir, allocator: Allocator, output_capture: ?*OutputCapture, input_source: ?*InputSource) !CommandStatus { - _ = allocator; - _ = input_source; + pub fn eval(mkdir: Mkdir, ctx: CommandContext) !CommandStatus { + _ = ctx.allocator; + _ = ctx.input_source; const dir_path = mkdir.path; @@ -24,7 +23,7 @@ pub const Mkdir = struct { error.NotDir => "The system cannot find the path specified\n", else => "Unable to create directory\n", }; - if (output_capture) |capture| { + if (ctx.output_capture) |capture| { try capture.write(error_msg); } else { print("{s}", .{error_msg}); |