-
-
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 some env vars to override config variables, but not command line arguments #2381
Allow some env vars to override config variables, but not command line arguments #2381
Conversation
d806d9b
to
386ac65
Compare
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.
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>
a1e5ec7
to
017e830
Compare
Thank you for reviewing @sharkdp! I'm happy with how this one came together. Should be ready to go. |
Thank you for the updates! |
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 inApp
to be removed as well.Right now, the env variables I picked are
BAT_TABS
,BAT_THEME
,BAT_PAGER
, andBAT_STYLE
as I think those make the most sense to replace. It is straightforward to add more if needed. Note thatBAT_PAGER
takes precedence over config variables, butPAGER
does not.Also adds tests for the
cache
subcommand to make sure the changes don't break it (e.g. by inserting flags beforecache
).Fixes #1152