pub fn get_config(key: &str, def: &str) -> String {
match std::env::var(key) {
Ok(val) => val,
Err(_) => def.to_string(),
}
}
#[test]
fn test_get_config() {
assert_eq!(get_config("CARGO_PKG_NAME", ""), "elk");
assert_eq!(get_config("CARGO__PKG_NAME", "default"), "default");
}