@@ 70,8 70,13 @@ pub fn parser(comptime Arg: type, comptime flags: []const Flag) type {
var i: usize = 0;
outer: while (i < args.len) : (i += 1) {
+ const arg = switch (Arg) {
+ [*:0]const u8 => mem.sliceTo(args[i], 0),
+ [:0]const u8 => args[i],
+ else => unreachable,
+ };
inline for (flags) |flag| {
- if (mem.eql(u8, "-" ++ flag.name, mem.span(args[i]))) {
+ if (mem.eql(u8, "-" ++ flag.name, arg)) {
switch (flag.kind) {
.boolean => @field(result_flags, flag.name) = true,
.arg => {
@@ 81,7 86,11 @@ pub fn parser(comptime Arg: type, comptime flags: []const Flag) type {
"' requires an argument but none was provided!", .{});
return error.MissingFlagArgument;
}
- @field(result_flags, flag.name) = mem.span(args[i]);
+ @field(result_flags, flag.name) = switch (Arg) {
+ [*:0]const u8 => mem.sliceTo(args[i], 0),
+ [:0]const u8 => args[i],
+ else => unreachable,
+ };
},
}
continue :outer;