Added envvar configuration

This commit is contained in:
Leonard Lorenz 2020-10-22 23:51:20 +02:00
parent b56dcdf330
commit 8a70db9b42
4 changed files with 31 additions and 11 deletions

12
src/config.rs Normal file
View 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);
}
})
}