Open VictorEijkhout opened 7 months ago
What sort of filtering do you want? Do you mean something like stopping at --
?
Stopping at --
seems like a reasonable solution.
Currently it does already stop at --
, but then it treats everything else as a positional argument. So you can almost get what you want by having no positional arguments and then fetching the unmatched arguments, which returns a vector of the remaining arguments.
I have previously changed this code to specifically not modify argv at all, because it was causing a lot of people problems to have argv as non const, and they weren't expecting argv to change.
Maybe one small change that would suit your use case is to make the last matched argc accessible. Then you can just pass &argv[new_argc]
to your second piece of code.
I'm using two libraries, one cxxopts, that both parse commandline arguments. I would appreciate it if cxxopts (which activates first) could return a filtered argc/argv pair.
Right now I do it by hand: 1. find a marker, 2. truncate argc and use that, and then 3. pass the remainder to the other library.