Skip to content

Commit a6c0e03

Browse files
committed
Fixed Multi-Value Parsing
- Fixed a logic issue that caused properly formatted Multi-Values to error out during parsing.
1 parent 2679c5c commit a6c0e03

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

src/Value.zig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,8 @@ pub fn Custom(comptime config: Config) type {
732732
}
733733
/// Get the inner Typed Value's Argument Index.
734734
pub fn argIdx(self: *const @This()) !?[]u8 {
735-
if (!include_arg_indices) return error.ArgIndicesNotEnabled;
735+
if (!include_arg_indices) //
736+
return error.ArgIndicesNotEnabled;
736737
return switch (meta.activeTag(self.*.generic)) {
737738
inline else => |tag| @field(self.*.generic, @tagName(tag)).arg_idx,
738739
};

src/cova.zig

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ fn parseArgsCtx(
586586
val_idx += 1;
587587
try val.setArgIdx(parse_ctx.arg_idx);
588588
parse_ctx.*.arg_idx += 1;
589-
log.debug("Parsed Value '{s}'.", .{ val.name() });
589+
log.debug("Parsed Value ({d}:{d}) '{s}'.", .{ val_idx, val.entryIdx(), val.name() });
590590
continue :parseArg;
591591
}
592592
}
@@ -652,10 +652,11 @@ fn parseArgsCtx(
652652
if (!parse_ctx.usage_help_flag) //
653653
parse_ctx.*.usage_help_flag = (cmd.checkFlag("help") or cmd.checkFlag("usage"));
654654
if ( //
655+
!parse_ctx.usage_help_flag and //
655656
cmd.vals_mandatory and //
656657
cmd.vals != null and //
657658
val_idx < cmd.vals.?.len and //
658-
!parse_ctx.usage_help_flag //
659+
!cmd.vals.?[0].isSet() //
659660
) {
660661
log.err("Command '{s}' expects {d} Value(s), but received {d}.", .{
661662
cmd.name,
@@ -677,11 +678,11 @@ fn parseOpt(args: *ArgIteratorGeneric, comptime OptionType: type, opt: *const Op
677678
if (peek_arg == null or peek_arg.?[0] == '-') {
678679
if (!(mem.eql(u8, opt.val.childType(), "bool"))) {
679680
if (opt.allow_empty) {
680-
opt.val.setEmpty() catch
681+
opt.val.setEmpty() catch //
681682
log.err("The Option '{s}' has already been set.", .{ opt.name });
682683
return;
683-
}
684-
else if (!opt.val.hasCustomParseFn())
684+
} //
685+
else if (!opt.val.hasCustomParseFn()) //
685686
return error.EmptyArgumentProvidedToOption;
686687
}
687688
_ = args.next();

0 commit comments

Comments
 (0)