-
Notifications
You must be signed in to change notification settings - Fork 500
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 --unstable to be set with an environment variable #1588
Conversation
b217508
to
f3609f9
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.
Just a few random nitpicks, see comments. Also: Is there any sort of convention regarding how other tools convert environment variable values are converted to bools? For example, Rust has the RUST_BACKTRACE
variable, which if unset or set to 0
will not capture a backtrace, but if set to any other value will. I wonder if there's any particular reason to go with one standard vs another.
src/config.rs
Outdated
@@ -3,6 +3,8 @@ use { | |||
clap::{App, AppSettings, Arg, ArgGroup, ArgMatches, ArgSettings}, | |||
}; | |||
|
|||
pub(crate) const UNSTABLE_KEY: &str = "JUST_ALLOW_UNSTABLE"; |
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 about JUST_UNSTABLE
instead? JUST_UNSTABLE=true
makes sense, and is shorter.
src/config.rs
Outdated
@@ -569,6 +571,9 @@ impl Config { | |||
None | |||
}; | |||
|
|||
let unstable = matches.is_present(arg::UNSTABLE) | |||
|| std::env::var_os(UNSTABLE_KEY).map_or(false, |val| val.to_string_lossy() == "true"); |
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'd be inclined to inline this:
|| std::env::var_os(UNSTABLE_KEY).map_or(false, |val| val.to_string_lossy() == "true"); | |
|| std::env::var_os("JUST_UNSTABLE").map_or(false, |val| val.to_string_lossy() == "true"); |
I'm not aware of any convention other than what seems reasonable from the perspective of a developer working with standard programming languages. I'd probably allow both "0" and "false" to be treated as a false boolean, the convention that setting the env var to anything else makes it true, seems reasonable to me. |
Allow the environment variable JUST_ALLOW_UNSTABLE=true to act as equivalent to the --unstable flag. Any other value of JUST_ALLOW_UNSTABLE is treated as false.
3d7cd62
to
5e395db
Compare
Tweaked a little bit and merged. Sorry for letting this sit for so long. In the mean time, |
Allow the environment variable JUST_ALLOW_UNSTABLE=true to act as equivalent to the --unstable flag. Any other value of JUST_ALLOW_UNSTABLE is treated as false.
This addresses #1575