Skip to content

Commit

Permalink
Fixed Empty Inline Short Options
Browse files Browse the repository at this point in the history
- Fixed an issue where inline Short Options wouldn't register.
  • Loading branch information
00JCIV00 committed Dec 13, 2024
1 parent a576742 commit 6350039
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/cova.zig
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ fn parseArgsCtx(
// Handle Argument provided to this Option with the Option/Value Separator (like '=') instead of ' '.
if (mem.indexOfScalar(u8, CommandT.OptionT.opt_val_seps, short_opts[short_idx + 1]) != null) {
if (mem.eql(u8, opt.val.childType(), "bool") and !opt.val.hasCustomParseFn()) {
log.err("The Option '{c}{?c}: {s}' is a Boolean/Toggle and cannot take an argument.", .{
short_pf,
opt.short_name,
opt.name
log.err("The Option '{c}{?c}: {s}' is a Boolean/Toggle and cannot take an argument.", .{
short_pf,
opt.short_name,
opt.name,
});
try errReaction(parse_config.err_reaction, opt, writer);
try writer.print("\n", .{});
Expand Down Expand Up @@ -410,6 +410,12 @@ fn parseArgsCtx(
log.debug("Parsed Option '{?c}'.", .{ opt.short_name });
continue :shortOpts;
}
// Handle a non-boolean Option that allows an Empty Value.
else if (opt.allow_empty) {
opt.val.setEmpty() catch
log.err("The Option '{s}' has already been set.", .{ opt.name });
continue :shortOpts;
}
// Handle a non-boolean Option which is given a Value without a space ' ' to separate them.
else if (CommandT.OptionT.allow_opt_val_no_space) {
var short_names_buf: [CommandT.max_args]u8 = undefined;
Expand Down

0 comments on commit 6350039

Please sign in to comment.