-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Allow env vars to override config variables, but not flags #1281
Allow env vars to override config variables, but not flags #1281
Conversation
Whoops, didn't mean to change that input file, lol. |
fade8de
to
36cddbf
Compare
Oh wait, I didn't realize Clap::Arg has an |
I was worried we might have to resort to using two different instances of clap to achieve this. This is a much more maintainable and elegant solution, great work! I'm currently on mobile so I can't give this a proper review, but if sharkdp or keith-hall don't beat me to it, I'll give it a look through in the morning. |
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.
Sorry for the delay. I've been a bit busy with university the past couple days, and haven't had the time to do any non-trivial reviews until today.
Great work on the pull request! Not only did this fix the issue, it removed some code that wasn't exactly easy to understand at a glance. Before I go ahead and merge this, I have two small requests:
-
Your changes use tabs for indentation, while the rest of the project uses spaces.
A quickcargo fmt
should fix that. -
If you could add an entry to the CHANGELOG.md file, I would appreciate it.
The format we use is as follows:- Description of what has been changed, see #123 (@user)
This comment has been minimized.
This comment has been minimized.
Also, a quick question: this is a breaking change of some sorts (for |
Well, that's not ideal. It doesn't seem to do that on my installation (latest stable), but I'll keep an eye out for it whenever I suggest running |
Oh dear.. I had an old from August 2019 version of I just pushed a commit where I ran |
Sorry about the formatting changes, my editor is supposedly configured to run rustfmt on save, so not sure why that didn't work correctly. Thanks! |
4c46e54
to
4591ccd
Compare
Thanks! For whatever reason,
Oh, that's fine. I think the forced checks are usually unnecessary, but I brought it up this time because mixed spaces/tabs is the bane of editors. |
@jacobmischka Thank you for this contribution. As far as I can tell, this does not fix #1152 so far, right? It's certainly a nice code simplification for the current behavior, but I'm not able to override config settings with environment variables. To reproduce: Add this to
Then, call:
Also, this change modifies the
|
Oh apologies, I thought I added an integration test for that but obviously I didn't. I'll look into it tonight hopefully and make sure it does. As for the help text, I think that can be fixed using the Thanks! |
Sure, no hurry! I am afraid that the actual solution to this will be quite a bit more involved :-/ |
Well, you weren't kidding. I admit this solution is a bit filthy, but hey all the test pass 😄! I wouldn't blame you if you had issues with mucking about with clap internals like this, but the previous Vec manipulation was slightly gross as it was already, ha. Also, I believe |
6983e0c
to
70be310
Compare
Ah, turns out |
70be310
to
4e36df6
Compare
@jacobmischka Thank you for the updates and the upstream PR. Let's come back to this as soon as your change has made it into a |
One year later and still no |
clap 3.0.0 has been released now 🎉 https://github.com/clap-rs/clap/releases/tag/v3.0.0 |
Parses env configurations into matches (for those that can be configured via matches) instead of relying on dedicated env checks everywhere. Fixes sharkdp#1152
Uses pretty gross match args manipulation.
My editor is supposed to do that for me...
Unfortunately this does not work.
4e36df6
to
0826b32
Compare
Unfortunately, clap 3 also breaks the method I was using to modify the arguments, they made that property private to the crate now. I updated this fork, but haven't found a better way to modify the matches. It's possible that there's a better, more supported way in clap 3 that I don't know about, I haven't looked super closely. But regardless, this needs work. I may return to it in the future, but certainly suggestions/help welcome. |
Closing to keep PR inbox clean. I added a note in #1152 that anyone looking to fix this problem to take a look at this PR. Of course feel free to re-open this PR if work resumes on it. |
Parses env configurations into matches (for those that can be configured
via matches) instead of relying on dedicated env checks everywhere.
Fixes #1152