Skip to content

Commit

Permalink
Updated Basic App Example and Tests
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
00JCIV00 committed Jul 18, 2024
1 parent 7ccfb9e commit 3aa4b03
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/basic_app.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/cova.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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();
}

0 comments on commit 3aa4b03

Please sign in to comment.