From 9b4bd1b10384bfdef3179a181ce7992a02286ca6 Mon Sep 17 00:00:00 2001 From: Jeremie Fraeys Date: Thu, 5 Mar 2026 10:30:55 -0500 Subject: [PATCH] refactor(cli): standardize dataset command format and remove redundant hash command Standardized dataset.zig with proper doc comment format: - Added /// doc comment with usage and subcommand descriptions - Follows same format as other commands Removed dataset_hash.zig: - Hash computation is already automatic in 'dataset verify' - Standalone 'ml dataset hash' command was redundant - Users can use 'ml dataset verify ' to get hash All tests pass. --- cli/src/commands/dataset_hash.zig | 49 ------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 cli/src/commands/dataset_hash.zig diff --git a/cli/src/commands/dataset_hash.zig b/cli/src/commands/dataset_hash.zig deleted file mode 100644 index cf58a8e..0000000 --- a/cli/src/commands/dataset_hash.zig +++ /dev/null @@ -1,49 +0,0 @@ -const std = @import("std"); -const cli = @import("../../main.zig"); -const hash_mod = @import("../../utils/hash.zig"); -const io = @import("../../utils/io.zig"); - -pub const name = "dataset hash"; -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) { - std.debug.print("Usage: ml dataset hash \n", .{}); - std.debug.print(" Path to dataset directory\n", .{}); - return; - } - - const path = args[0]; - - // Hash the directory - io.printInfo("Hashing dataset at: {s}\n", .{path}); - - const hash = hash_mod.hashDirectoryToHex(allocator, path) catch |err| { - switch (err) { - error.PathTraversalAttempt => { - io.printError("Invalid path (path traversal detected): {s}\n", .{path}); - }, - error.NotAFile => { - io.printError("Not a regular file: {s}\n", .{path}); - }, - error.EmptyDirectory => { - io.printError("Directory is empty or contains no files: {s}\n", .{path}); - }, - error.MaxDepthExceeded => { - io.printError("Max directory depth exceeded (32): {s}\n", .{path}); - }, - error.OutOfMemory => { - io.printError("Out of memory\n", .{}); - }, - else => { - io.printError("Hash computation failed: {s}\n", .{@errorName(err)}); - }, - } - return err; - }; - defer allocator.free(hash); - - // Print result - io.printSuccess("Dataset hash: {s}\n", .{hash}); -}