refactor(cli): update protocol and main entry point

Update core protocol and application structure:
- protocol.zig: enhanced binary protocol handling
- main.zig: updated entry point for new command structure
- manifest.zig: improved manifest handling

Part of CLI hardening architecture improvements.
This commit is contained in:
Jeremie Fraeys 2026-03-04 20:25:40 -05:00
parent 89635b1d8c
commit dbecb2b521
No known key found for this signature in database
3 changed files with 12 additions and 3 deletions

View file

@ -37,7 +37,9 @@ pub fn main() !void {
'a' => if (std.mem.eql(u8, command, "annotate")) {
try @import("commands/annotate.zig").execute(allocator, args[2..]);
} else handleUnknownCommand(command),
'e' => if (std.mem.eql(u8, command, "experiment")) {
'e' => if (std.mem.eql(u8, command, "exec")) {
try @import("commands/exec.zig").execute(allocator, args[2..]);
} else if (std.mem.eql(u8, command, "experiment")) {
try @import("commands/experiment.zig").execute(allocator, args[2..]);
} else if (std.mem.eql(u8, command, "export")) {
try @import("commands/export_cmd.zig").run(allocator, args[2..]);
@ -91,6 +93,7 @@ fn printUsage() void {
std.debug.print("ML Experiment Manager\n\n", .{});
std.debug.print("Usage: ml <command> [options]\n\n", .{});
std.debug.print("Commands:\n", .{});
std.debug.print(" exec <job> Execute job (auto local/remote)\n", .{});
std.debug.print(" init Initialize project with config\n", .{});
std.debug.print(" run [args] Execute a run locally\n", .{});
std.debug.print(" queue <job> Queue job on server\n", .{});

View file

@ -288,7 +288,10 @@ pub fn updateManifestStatus(path: []const u8, status: []const u8, exit_code: ?i3
day_seconds.getHoursIntoDay(),
day_seconds.getMinutesIntoHour(),
day_seconds.getSecondsIntoMinute(),
}) catch unreachable;
}) catch |err| {
std.log.err("Failed to format timestamp: {}", .{err});
return error.TimestampFormatError;
};
manifest.ended_at = try allocator.dupe(u8, timestamp);

View file

@ -385,7 +385,10 @@ test "deserialize data packet (varint lengths)" {
const allocator = std.testing.allocator;
// PacketTypeData (0x04), timestamp=1 (big-endian)
var buf = std.ArrayList(u8).initCapacity(allocator, 64) catch unreachable;
var buf = std.ArrayList(u8).initCapacity(allocator, 64) catch |err| {
std.log.err("Failed to allocate buffer: {}", .{err});
return;
};
defer buf.deinit(allocator);
try buf.append(allocator, 0x04);