summaryrefslogtreecommitdiff
path: root/src/cmd/lib
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2025-08-15 13:43:22 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2025-08-15 13:43:22 +0200
commit6f84a9a1458ff053d6dc7c1a66c1e03deb8e8793 (patch)
treeeb7e23e0f58bdbb3e40ba73a21d13b65fea18b5f /src/cmd/lib
parente8dbb3c17c93372a771a7a26900ae05754b217dc (diff)
CommandContext: Add execute_command back, properly typed.
Diffstat (limited to 'src/cmd/lib')
-rw-r--r--src/cmd/lib/types.zig9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/cmd/lib/types.zig b/src/cmd/lib/types.zig
index 5990511..c1ce3c7 100644
--- a/src/cmd/lib/types.zig
+++ b/src/cmd/lib/types.zig
@@ -2,6 +2,9 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
+const cmd = @import("../../cmd.zig");
+const Command = cmd.Command;
+
pub const CommandStatus = union(enum) {
Code: u16,
ExitShell,
@@ -62,16 +65,20 @@ pub const InputSource = struct {
}
};
+pub const ExecuteCommandFn = *const fn (Command, Allocator, ?*OutputCapture, ?*InputSource) anyerror!CommandStatus;
+
pub const CommandContext = struct {
allocator: Allocator,
output_capture: ?*OutputCapture,
input_source: ?*InputSource,
+ execute_command: ExecuteCommandFn,
- pub fn init(allocator: Allocator, output_capture: ?*OutputCapture, input_source: ?*InputSource) CommandContext {
+ pub fn init(allocator: Allocator, output_capture: ?*OutputCapture, input_source: ?*InputSource, execute_command: ExecuteCommandFn) CommandContext {
return CommandContext{
.allocator = allocator,
.output_capture = output_capture,
.input_source = input_source,
+ .execute_command = execute_command,
};
}
};