Allow some env vars to override config variables, but not command line arguments - #2381
Merged
sharkdp merged 9 commits intoNov 2, 2022
Merged
Conversation
aaronkollasch
commented
Oct 26, 2022
aaronkollasch
force-pushed
the
env-override-config-not-flags
branch
3 times, most recently
from
October 28, 2022 19:31
d806d9b to
386ac65
Compare
sharkdp
reviewed
Nov 2, 2022
sharkdp
reviewed
Nov 2, 2022
sharkdp
reviewed
Nov 2, 2022
sharkdp
reviewed
Nov 2, 2022
sharkdp
reviewed
Nov 2, 2022
sharkdp
reviewed
Nov 2, 2022
sharkdp
approved these changes
Nov 2, 2022
sharkdp
left a comment
Owner
There was a problem hiding this comment.
What an excellent PR. Good description, a ChangeLog entry, useful and sensible unit tests. And a really cool idea for implementing this feature that I hadn't thought of. Thank you very much!
Added some minor remarks as inline comments.
Treat the cache subcommand differently from --no-config: For --no-config, insert args from selected environment variables For cache, don't insert args
Co-authored-by: David Peter <sharkdp@users.noreply.github.com>
Co-authored-by: David Peter <sharkdp@users.noreply.github.com>
aaronkollasch
force-pushed
the
env-override-config-not-flags
branch
from
November 2, 2022 21:15
a1e5ec7 to
017e830
Compare
Contributor
Author
|
Thank you for reviewing @sharkdp! I'm happy with how this one came together. Should be ready to go. |
Owner
|
Thank you for the updates! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Giving #1281 a go.
This PR allows certain environment variables to take precedence over config settings, while allowing them to be overridden by their respective command line flags.
It does this by formatting those variables as a vector of command line args, and then inserting them between the config variables and command line args in
App::matches(). Parsing the env variables in that way allows some env variable-specific code inAppto be removed as well.Right now, the env variables I picked are
BAT_TABS,BAT_THEME,BAT_PAGER, andBAT_STYLEas I think those make the most sense to replace. It is straightforward to add more if needed. Note thatBAT_PAGERtakes precedence over config variables, butPAGERdoes not.Also adds tests for the
cachesubcommand to make sure the changes don't break it (e.g. by inserting flags beforecache).Fixes #1152