refactor: lots and lots of writergate changes

This commit is contained in:
CJ van den Berg 2025-09-24 22:30:18 +02:00
parent 96e8100373
commit e6b39c274c
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
19 changed files with 437 additions and 382 deletions

View file

@ -3,7 +3,7 @@ const tp = @import("thespian");
const shell = @import("shell");
const bin_path = @import("bin_path");
pub const Error = error{ OutOfMemory, GitNotFound, GitCallFailed };
pub const Error = error{ OutOfMemory, GitNotFound, GitCallFailed, WriteFailed };
const log_execute = false;
@ -208,15 +208,16 @@ fn git_err(
) Error!void {
const cbor = @import("cbor");
const git_binary = get_git() orelse return error.GitNotFound;
var buf: std.ArrayListUnmanaged(u8) = .empty;
const writer = buf.writer(allocator);
var buf: std.Io.Writer.Allocating = .init(allocator);
defer buf.deinit();
const writer = &buf.writer;
switch (@typeInfo(@TypeOf(cmd))) {
.@"struct" => |info| if (info.is_tuple) {
try cbor.writeArrayHeader(writer, info.fields.len + 1);
try cbor.writeValue(writer, git_binary);
inline for (info.fields) |f|
try cbor.writeValue(writer, @field(cmd, f.name));
return shell.execute(allocator, .{ .buf = buf.items }, .{
return shell.execute(allocator, .{ .buf = buf.written() }, .{
.context = context,
.out = to_shell_output_handler(out),
.err = to_shell_output_handler(err),