diff options
Diffstat (limited to 'clap')
| -rw-r--r-- | clap/comptime.zig | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clap/comptime.zig b/clap/comptime.zig index edbaafb..99f0be6 100644 --- a/clap/comptime.zig +++ b/clap/comptime.zig | |||
| @@ -39,7 +39,7 @@ pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) | |||
| 39 | allocator: *mem.Allocator, | 39 | allocator: *mem.Allocator, |
| 40 | 40 | ||
| 41 | pub fn parse(allocator: *mem.Allocator, comptime ArgIter: type, iter: *ArgIter) !@This() { | 41 | pub fn parse(allocator: *mem.Allocator, comptime ArgIter: type, iter: *ArgIter) !@This() { |
| 42 | var multis = [_]std.ArrayList([]const u8){undefined} ** single_options; | 42 | var multis = [_]std.ArrayList([]const u8){undefined} ** multi_options; |
| 43 | for (multis) |*multi| { | 43 | for (multis) |*multi| { |
| 44 | multi.* = std.ArrayList([]const u8).init(allocator); | 44 | multi.* = std.ArrayList([]const u8).init(allocator); |
| 45 | } | 45 | } |
| @@ -64,13 +64,16 @@ pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) | |||
| 64 | try pos.append(arg.value.?); | 64 | try pos.append(arg.value.?); |
| 65 | } else if (param.takes_value == .One) { | 65 | } else if (param.takes_value == .One) { |
| 66 | debug.assert(res.single_options.len != 0); | 66 | debug.assert(res.single_options.len != 0); |
| 67 | res.single_options[param.id] = arg.value.?; | 67 | if (res.single_options.len != 0) |
| 68 | res.single_options[param.id] = arg.value.?; | ||
| 68 | } else if (param.takes_value == .Many) { | 69 | } else if (param.takes_value == .Many) { |
| 69 | debug.assert(res.multi_options.len != 0); | 70 | debug.assert(multis.len != 0); |
| 70 | try multis[param.id].append(arg.value.?); | 71 | if (multis.len != 0) |
| 72 | try multis[param.id].append(arg.value.?); | ||
| 71 | } else { | 73 | } else { |
| 72 | debug.assert(res.flags.len != 0); | 74 | debug.assert(res.flags.len != 0); |
| 73 | res.flags[param.id] = true; | 75 | if (res.flags.len != 0) |
| 76 | res.flags[param.id] = true; | ||
| 74 | } | 77 | } |
| 75 | } | 78 | } |
| 76 | 79 | ||