Load global configuration from the default location
()
| 361 | impl GlobalConfig { |
| 362 | /// Load global configuration from the default location |
| 363 | pub fn load() -> Result<Self, ConfigError> { |
| 364 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 365 | |
| 366 | if !path.exists() { |
| 367 | return Ok(Self::default()); |
| 368 | } |
| 369 | |
| 370 | let content = std::fs::read_to_string(&path).map_err(|e| ConfigError::ReadError { |
| 371 | path: path.clone(), |
| 372 | source: e, |
| 373 | })?; |
| 374 | |
| 375 | Ok(toml::from_str(&content)?) |
| 376 | } |
| 377 | |
| 378 | /// Save global configuration to the default location |
| 379 | pub fn save(&self) -> Result<(), ConfigError> { |
no test coverage detected