From 3aa4b034d628596c4074a8d6add330a5af5b988b Mon Sep 17 00:00:00 2001 From: 00JCIV00 Date: Thu, 18 Jul 2024 01:35:52 -0400 Subject: [PATCH] Updated Basic App Example and Tests - Updated Basic App Example f/ Cova v0.10.0 and Zig v0.13.0 changes. - Updated Tests f/ Cova v0.10.0 changes. - Thank you @PalanixYT for pointing these out! #58 --- examples/basic_app.zig | 6 +++--- src/cova.zig | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/basic_app.zig b/examples/basic_app.zig index 8514847..87d80bd 100644 --- a/examples/basic_app.zig +++ b/examples/basic_app.zig @@ -238,7 +238,7 @@ pub fn open(filename: []const u8) !std.fs.File { break :filenameChecked (try std.fmt.bufPrint(fnc_buf[0..], "{s}.csv", .{ filename }))[0..(filename.len + 4)]; }; const open_file = try std.fs.cwd().createFile(filename_checked, .{ .read = true, .truncate = false }); - try std.fs.cwd().writeFile(".ba_persist", filename_checked); + try std.fs.cwd().writeFile(.{ .sub_path = ".ba_persist", .data = filename_checked }); return open_file; } @@ -294,12 +294,12 @@ pub fn main() !void { // The `cova.utils.displayCmdInfo()` function is useful for seeing the results of a parsed // Command. This is done recursively for any sub Argument Types within the Command and can be // used to debug said Command. - if (builtin.mode == .Debug) try cova.utils.displayCmdInfo(CommandT, main_cmd, alloc, &stdout); + if (builtin.mode == .Debug) try cova.utils.displayCmdInfo(CommandT, main_cmd, alloc, &stdout, true); // - App Vars var user_filename_buf: [100]u8 = .{ 0 } ** 100; _ = std.fs.cwd().readFile(".ba_persist", user_filename_buf[0..]) catch { - try std.fs.cwd().writeFile(".ba_persist", "users.csv"); + try std.fs.cwd().writeFile(.{ .sub_path = ".ba_persist", .data = "users.csv" }); for (user_filename_buf[0..9], "users.csv") |*u, c| u.* = c; }; const ufb_end = std.mem.indexOfScalar(u8, user_filename_buf[0..], 0) orelse 9; diff --git a/src/cova.zig b/src/cova.zig index 859158b..32e76af 100644 --- a/src/cova.zig +++ b/src/cova.zig @@ -591,7 +591,7 @@ fn parseArgsCtx( val_idx < cmd.vals.?.len and !parse_ctx.usage_help_flag ) { - log.err("Command '{s}' expects {d} Values, but only received {d}.", .{ + log.err("Command '{s}' expects {d} Value(s), but received {d}.", .{ cmd.name, cmd.vals.?.len, val_idx, @@ -840,7 +840,7 @@ test "argument analysis" { } }; - try utils.displayCmdInfo(TestCommand, test_cmd, alloc, writer); + try utils.displayCmdInfo(TestCommand, test_cmd, alloc, writer, false); //_ = test_setup_cmd.SubCommandsEnum(); }