-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix: Remove overriden occurrences as we go #3225
Conversation
This makes some naming more explicit and allows us to increment occurrences before adding values (which is the logical mental order and allows other improvements).
This is the logical order people think in terms of (`--foo` comes before `val` in `--foo val`). This also opens things up for using occurrence incrementing as a place to handle occurrence transitions, like overrides.
This will have a slight performance hit as `AllArgsOverrideSelf` will allocate a single-element `Vec` per `Arg`. This can be lessened for positional and multiple occurrences by shifting those checks up into the propagation check. Long term, I'd like to see all of the `Arg`-in-`App` settings switch to this which will make it easier for callers, like completions and man pages, to figure out whats going on without duplicating the logic. Short term, this is motivated by wanting to change the override logic to accomodated interleaved overrides from clap-rs#3217. Moving this logic will make it easier to change the override logic.
This allows two overriding args to interact with each other mid-line. This was broken in 7673dfc / clap-rs#1154. Before that, we duplicated the override logic in several places. Now we plug into the start of a new arg which allows us to do this incrementally without making the logic complex or inefficient, thanks to prior refactors. Fixes clap-rs#3217
// | ||
// We can evaluate switching this to a debug assert at a later time (though it will | ||
// require changing propagation of `AllArgsOverrideSelf`). Being conservative for now | ||
// due to where we are at in the release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that we released, can we add a debug assert for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think doing so would be a breaking change. This was written assuming we wouldn't be changing it for 3.x because it didn't seem worth addressing in our current time frame.
This allows two overriding args to interact with each other mid-line.
This was broken in 7673dfc / #1154. Before that, we duplicated the override
logic in several places.
Now we plug into the start of a new arg which allows us to do this
incrementally without making the logic complex or inefficient, thanks to
the refactors in this PR.
Fixes #3217