From b01e93502ec5de0c4017ee72ad8c683fcf5dab2a Mon Sep 17 00:00:00 2001 From: Halil Durak Date: Fri, 10 Apr 2026 15:14:37 +0300 Subject: [PATCH] `cli`: revert enum specific peek ahead logic This was needed before the introduction of `validator`; doesn't make sense now. --- src/cli.zig | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/cli.zig b/src/cli.zig index 431a32cf3..d17947858 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -329,25 +329,19 @@ pub fn Builder(comptime commands: anytype) type { } }, .@"enum" => { - if (is_multiple) { - @compileError("multiple option is not supported for enums"); - } - const E = switch (@typeInfo(T)) { .optional => |optional| optional.child, inline else => T, }; - // This type only, we peek ahead to check if there's a following arg. - // If there isn't, the default is set already. - var peek_args = args.*; - if (peek_args.next()) |next_arg| { - const v = std.meta.stringToEnum(E, next_arg) orelse { - return error.UnknownArgument; - }; - // Discard. - _ = args.next(); + // TODO: Return errors. + const v = std.meta.stringToEnum(E, args.next().?) orelse { + return error.UnknownArgument; + }; + if (is_multiple) { + try @field(c, option.name).append(allocator, v); + } else { @field(c, option.name) = v; } },