From 6350039320de264ff6a7b300bed5fee32afc9774 Mon Sep 17 00:00:00 2001 From: 00JCIV00 Date: Fri, 13 Dec 2024 18:23:51 -0500 Subject: [PATCH] Fixed Empty Inline Short Options - Fixed an issue where inline Short Options wouldn't register. --- src/cova.zig | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cova.zig b/src/cova.zig index 9b280ba..70e1ea7 100644 --- a/src/cova.zig +++ b/src/cova.zig @@ -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", .{}); @@ -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;