-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Should override with last given value when incompatible options are used #491
Comments
Other conflicting options are
|
We need to tread carefully here. We can't just say "these flags conflict and therefore produce an error if both are provided." A more measured strategy is required IMO. We might want to say that between I believe clap supports flags that mutually override each other, although I can't remember the precise semantics off the top of my head. |
Your initial examples with With all that said, I'm somewhat skeptical of forcing a hard error on conflict, and instead try to define sensible semantics for each combination. The former gives the end user less flexibility, and in my experience, with the number of flags that ripgrep supports, end users can be intensely creative in the types of flag combinations they come up with. It would be a shame to start a crusade to decrease the ability to be creative. Thoughts? |
I haven't thought about overriding. Sure, is more flexible and gives a better user experience. This is from the clap README:
|
We're not completely able to override last options with previous ones as clap does not allow that in some cases, as reported in clap-rs/clap#970 and clap-rs/clap#976. Some minimal changes in this direction, using what we can get from clap, are in #499. I was experimenting with rust-argparse and it looks like a much simpler, yet more flexible solution. It's API is more similar to the C POSIX implementation in the sense that variables are set in a loop, so last assignments "win". Also, no bells and whistles like color output. On the other hand: choices, and required and conflicting arguments would need to be handled manually with rust-argparse. |
@ericbn Thanks for looking into this. I've only briefly glanced at the clap issues. I will say this though: I really do not want to switch argv parsers. Note that I don't particularly care that much about POSIX per se, but care more about just ironing out a decent user experience. So if there are corner cases that aren't strictly compatible with POSIX but don't have a big impact on actual uses, then I'm fine with that. (And of course, I understand that "POSIX compatibility" can be treated as an approximation to good UX because it is familiar.) |
@BurntSushi, sounds good. I don't care about "POSIX compatibility" either, I just think the "last overrides previous" and other characteristics present these make sense for a good UX. I'll close this and hope we can see improvements in clap and make use of them in the future... |
Just to follow up on the general argv parser discussion, |
@ericbn Thanks! That's a useful data point. ripgrep will definitely not grow its own argv parser though. :-) |
That I can think of, is does not make sense to have
--vimgrep
and--count
--vimgrep
and--heading
--vimgrep
and--pretty
both at the same time. As vimgrep is trying to ouput
and the other options conflict with this. It would not make sense to have vimgrep with
--no-line-number
or--no-filename
either, but these would just generate "useless" output...@BurntSushi, do you agree rg should fail if conflicting arguments are passed?
The text was updated successfully, but these errors were encountered: