diff --git a/cli/src/utils/io.zig b/cli/src/utils/io.zig index 4b7d698..82800f0 100644 --- a/cli/src/utils/io.zig +++ b/cli/src/utils/io.zig @@ -243,3 +243,48 @@ pub fn jsonGetBool(obj: std.json.ObjectMap, key: []const u8) ?bool { if (v != .bool) return null; return v.bool; } + +// ============================================================================ +// Logging Utilities (consolidated from logging.zig) +// ============================================================================ + +fn printWithColor(comptime color_code: []const u8, comptime format: []const u8, args: anytype) void { + const stderr = std.io.getStdErr().writer(); + stderr.print(color_code ++ format ++ reset ++ "\n", args) catch {}; +} + +pub fn printInfo(comptime format: []const u8, args: anytype) void { + printWithColor(blue, format, args); +} + +pub fn printSuccess(comptime format: []const u8, args: anytype) void { + printWithColor(green, format, args); +} + +pub fn printWarning(comptime format: []const u8, args: anytype) void { + printWithColor(yellow, format, args); +} + +pub fn printError(comptime format: []const u8, args: anytype) void { + printWithColor(red, format, args); +} + +pub fn printProgress(comptime format: []const u8, args: anytype) void { + const stdout = std.io.getStdOut().writer(); + stdout.print(format ++ "\n", args) catch {}; +} + +pub fn confirm(comptime prompt: []const u8, args: anytype) bool { + const stdin = std.io.getStdIn().reader(); + const stdout = std.io.getStdOut().writer(); + + stdout.print(bold ++ prompt ++ reset ++ " [y/N] ", args) catch {}; + + var buf: [10]u8 = undefined; + if (stdin.readUntilDelimiterOrEof(&buf, '\n')) |input| { + if (input) |line| { + return line.len > 0 and (line[0] == 'y' or line[0] == 'Y'); + } + } else |_| {} + return false; +} diff --git a/cli/src/utils/logging.zig b/cli/src/utils/logging.zig deleted file mode 100644 index a6df7ea..0000000 --- a/cli/src/utils/logging.zig +++ /dev/null @@ -1,27 +0,0 @@ -const std = @import("std"); -const colors = @import("colors.zig"); - -/// Simple logging utility that wraps colors functionality -pub fn info(comptime format: []const u8, args: anytype) void { - colors.printInfo(format, args); -} - -pub fn success(comptime format: []const u8, args: anytype) void { - colors.printSuccess(format, args); -} - -pub fn warn(comptime format: []const u8, args: anytype) void { - colors.printWarning(format, args); -} - -pub fn err(comptime format: []const u8, args: anytype) void { - colors.printError(format, args); -} - -pub fn progress(comptime format: []const u8, args: anytype) void { - colors.printProgress(format, args); -} - -pub fn confirm(comptime prompt: []const u8, args: anytype) bool { - return colors.confirm(prompt, args); -}