Added envvar configuration
This commit is contained in:
parent
b56dcdf330
commit
8a70db9b42
4 changed files with 31 additions and 11 deletions
12
src/config.rs
Normal file
12
src/config.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
use std::string::String;
|
||||
|
||||
pub fn get_from_env(variable: &str, mandatory: bool) -> String {
|
||||
std::env::var(variable).unwrap_or_else(|_| {
|
||||
if mandatory {
|
||||
println!("Error, couldn't read environment variable: {}", variable);
|
||||
std::process::exit(1);
|
||||
} else {
|
||||
panic!("Error, couldn't read environment variable: {}", variable);
|
||||
}
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue