blob: 5eb06cc1a60a4b6c813d46ef041055a9b1e72545 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#[cfg(not(test))]
use std::env;
/// If `name` is set and, after trimming whitespace, is not empty string, then return that trimmed
/// string. Else None.
pub fn get_env_var(_name: &str) -> Option<String> {
#[cfg(not(test))]
match env::var(_name).unwrap_or_else(|_| "".to_string()).trim() {
"" => None,
non_empty_string => Some(non_empty_string.to_string()),
}
#[cfg(test)]
None
}
/// If `name` is set to any value at all (including "") then return true; else false.
pub fn get_boolean_env_var(_name: &str) -> bool {
#[cfg(not(test))]
{
env::var(_name).ok().is_some()
}
#[cfg(test)]
false
}
|