Skip to content

Commit

Permalink
treat all arguments after '--' as positionals
Browse files Browse the repository at this point in the history
  • Loading branch information
n0s4 committed May 28, 2024
1 parent d9b8628 commit c7afce4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ fn parseFlags(args: *ArgIterator, comptime Flags: type, comptime command_name: [
continue :next_arg;
}

if (std.mem.eql(u8, arg, "--")) {
// Blindly treat the remaining flags as positional arguments
while (args.next()) |pos| {
if (positional_count == max_positional_args) fatal("too many arguments", .{});
positionals[positional_count] = pos;
positional_count += 1;
}
break;
}

if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) {
printHelp(Flags, command_name);
}
Expand Down

0 comments on commit c7afce4

Please sign in to comment.