refactor(cli): remove logging.zig, consolidate into io.zig
Remove redundant logging.zig (28 lines): - Functions moved to io.zig: printInfo, printSuccess, printWarning, printError, printProgress, confirm - All functionality preserved with re-exports in utils.zig Benefits: - Reduced file count (22 → 21 utils) - Single source of truth for I/O operations - No functional changes Build passes successfully.
This commit is contained in:
parent
cf7e82c758
commit
5b0bd83bd7
2 changed files with 45 additions and 27 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
Loading…
Reference in a new issue