From 41ac75b6db818ce9431d145d5a9e335cf38cc117 Mon Sep 17 00:00:00 2001 From: Asherah Connor Date: Fri, 28 Aug 2020 15:57:36 +1000 Subject: fix up --- clap/comptime.zig | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'clap') 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)) allocator: *mem.Allocator, pub fn parse(allocator: *mem.Allocator, comptime ArgIter: type, iter: *ArgIter) !@This() { - var multis = [_]std.ArrayList([]const u8){undefined} ** single_options; + var multis = [_]std.ArrayList([]const u8){undefined} ** multi_options; for (multis) |*multi| { multi.* = std.ArrayList([]const u8).init(allocator); } @@ -64,13 +64,16 @@ pub fn ComptimeClap(comptime Id: type, comptime params: []const clap.Param(Id)) try pos.append(arg.value.?); } else if (param.takes_value == .One) { debug.assert(res.single_options.len != 0); - res.single_options[param.id] = arg.value.?; + if (res.single_options.len != 0) + res.single_options[param.id] = arg.value.?; } else if (param.takes_value == .Many) { - debug.assert(res.multi_options.len != 0); - try multis[param.id].append(arg.value.?); + debug.assert(multis.len != 0); + if (multis.len != 0) + try multis[param.id].append(arg.value.?); } else { debug.assert(res.flags.len != 0); - res.flags[param.id] = true; + if (res.flags.len != 0) + res.flags[param.id] = true; } } -- cgit v1.2.3