(&self)
| 198 | |
| 199 | impl StringKey<'_> { |
| 200 | pub fn get_value(&self) -> String { |
| 201 | let config = get_config().unwrap_or_default(); |
| 202 | let keys = self.0.to_owned(); |
| 203 | let default_value = self.1.to_owned(); |
| 204 | let mut result; |
| 205 | for key in keys { |
| 206 | if config.contains_key(key) { |
| 207 | result = config[key].as_str().unwrap().to_string() |
| 208 | } else { |
| 209 | result = env::var(get_env_name(key)).unwrap_or_default() |
| 210 | } |
| 211 | if key.eq(CACHE_PATH_KEY) { |
| 212 | // The configuration key for the cache path ("cache-path") is special because |
| 213 | // the rest of the configuration values depend on this value (since the |
| 214 | // configuration file is stored in the cache path). Therefore, this value needs |
| 215 | // to be discovered in the first place and stored globally (on CACHE_PATH) |
| 216 | return check_cache_path(result, default_value); |
| 217 | } |
| 218 | if !result.is_empty() { |
| 219 | return result; |
| 220 | } |
| 221 | } |
| 222 | default_value |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | pub struct IntegerKey<'a>(pub &'a str, pub u64); |
no test coverage detected