I'm trying to make an arg that accepts one or two comma-delimited values, and also accept unnamed (index) argument after that.
prog -q 1,2 file # OK: parses as q=[1,2]; input=file
prog -q 1 file # should parse as q=[1]; input=file; but parses as q=[1,file]; input missing
The problem is that multiple arguments allow spaces, which causes ambiguity. I don't know how to disable that.
Currently, there isn't a way to _force_ the use of a delimiter. That is something that could be added.
But there are few other things about this scenario too: Is there a limit on the number of values for q? Otherwise, prog -q 1,2 file won't parse like q=[1,2]; input=file
I could consider this a bug, so-to-speak. i.e. if a delimiter is present, parsing something after a space probably shouldn't be part of the same value group. This still doesn't help your scenario 2 though. To go along with the above "bug" is parsing something like -q=1 file shouldn't lump file in with -q, but currently does.
So, would solving those two bugs suffice, or would a force_delimiter still be preferred? i.e.
= is present, don't parse anything after a space as the same group of valuesThis would allow you to do -q=1 file and the option of either -q 1,2 file or -q=1,2 file all parsing correctly.
My only issue with the I would assume most people, upon realizing require_delimiter type thing, is it seems somewhat niche assuming the above bugs are fixed.-q 1 file isn't working would try -q=1 file next.
Edit: thinking about it more, I'm good adding the require_delimiter, but still want some thoughts on the matter :)
Thank you for your response.
In my case it's strictly 1 or 2 values for q. require_delimiter would be ideal for me, as -q 1 file case is going to be the most common in my program.
Arg::require_delimiter in a new PR and upload as v2.8.0 to crates.io to keep all SemVer users aware of changes.Fantastic! Thank you!
Arg::require_delimiter isn't implemented yet, doing so now :wink:
I want to keep this open just a tracking issue for that, until the PR merges.
This will be fully implemented with #551