diff --git a/cli/src/commands/dataset_hash.zig b/cli/src/commands/dataset_hash.zig index fa2618b..cf58a8e 100644 --- a/cli/src/commands/dataset_hash.zig +++ b/cli/src/commands/dataset_hash.zig @@ -1,8 +1,7 @@ const std = @import("std"); const cli = @import("../../main.zig"); const hash_mod = @import("../../utils/hash.zig"); -const ui = @import("../../ui/ui.zig"); -const colors = @import("../../ui/colors.zig"); +const io = @import("../../utils/io.zig"); pub const name = "dataset hash"; pub const description = "Hash a dataset directory using SHA256"; @@ -10,36 +9,35 @@ pub const description = "Hash a dataset directory using SHA256"; pub fn run(allocator: std.mem.Allocator, args: []const []const u8) !void { // Parse arguments if (args.len < 1) { - try ui.printHelp(name, description, &.{ - .{ "", "Path to dataset directory" }, - }); + std.debug.print("Usage: ml dataset hash \n", .{}); + std.debug.print(" Path to dataset directory\n", .{}); return; } const path = args[0]; // Hash the directory - colors.printInfo("Hashing dataset at: {s}\n", .{path}); + io.printInfo("Hashing dataset at: {s}\n", .{path}); const hash = hash_mod.hashDirectoryToHex(allocator, path) catch |err| { switch (err) { error.PathTraversalAttempt => { - colors.printError("Invalid path (path traversal detected): {s}\n", .{path}); + io.printError("Invalid path (path traversal detected): {s}\n", .{path}); }, error.NotAFile => { - colors.printError("Not a regular file: {s}\n", .{path}); + io.printError("Not a regular file: {s}\n", .{path}); }, error.EmptyDirectory => { - colors.printError("Directory is empty or contains no files: {s}\n", .{path}); + io.printError("Directory is empty or contains no files: {s}\n", .{path}); }, error.MaxDepthExceeded => { - colors.printError("Max directory depth exceeded (32): {s}\n", .{path}); + io.printError("Max directory depth exceeded (32): {s}\n", .{path}); }, error.OutOfMemory => { - colors.printError("Out of memory\n", .{}); + io.printError("Out of memory\n", .{}); }, else => { - colors.printError("Hash computation failed: {s}\n", .{@errorName(err)}); + io.printError("Hash computation failed: {s}\n", .{@errorName(err)}); }, } return err; @@ -47,5 +45,5 @@ pub fn run(allocator: std.mem.Allocator, args: []const []const u8) !void { defer allocator.free(hash); // Print result - colors.printSuccess("Dataset hash: {s}\n", .{hash}); + io.printSuccess("Dataset hash: {s}\n", .{hash}); }