Load global configuration from the default location
()
| 379 | impl GlobalConfig { |
| 380 | /// Load global configuration from the default location |
| 381 | pub fn load() -> Result<Self, ConfigError> { |
| 382 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 383 | |
| 384 | if !path.exists() { |
| 385 | return Ok(Self::default()); |
| 386 | } |
| 387 | |
| 388 | let content = std::fs::read_to_string(&path).map_err(|e| ConfigError::ReadError { |
| 389 | path: path.clone(), |
| 390 | source: e, |
| 391 | })?; |
| 392 | |
| 393 | Ok(toml::from_str(&content)?) |
| 394 | } |
| 395 | |
| 396 | /// Save global configuration to the default location |
| 397 | pub fn save(&self) -> Result<(), ConfigError> { |
no test coverage detected