fix(cli): fix broken imports in dataset_hash.zig
Fix broken imports in dataset_hash.zig: - ui/ui.zig and ui/colors.zig don't exist - replaced with std.debug.print - Updated colors. to io. for consistency with consolidated utilities - Remove dependency on non-existent ui module All tests pass.
This commit is contained in:
parent
38fe9aba73
commit
6c192e5144
1 changed files with 11 additions and 13 deletions
|
|
@ -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>", "Path to dataset directory" },
|
||||
});
|
||||
std.debug.print("Usage: ml dataset hash <path>\n", .{});
|
||||
std.debug.print(" <path> 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});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue