Load global configuration from the default location
()
| 441 | impl GlobalConfig { |
| 442 | /// Load global configuration from the default location |
| 443 | pub fn load() -> Result<Self, ConfigError> { |
| 444 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 445 | |
| 446 | if !path.exists() { |
| 447 | return Ok(Self::default()); |
| 448 | } |
| 449 | |
| 450 | let content = std::fs::read_to_string(&path).map_err(|e| ConfigError::ReadError { |
| 451 | path: path.clone(), |
| 452 | source: e, |
| 453 | })?; |
| 454 | |
| 455 | Ok(toml::from_str(&content)?) |
| 456 | } |
| 457 | |
| 458 | /// Save global configuration to the default location |
| 459 | pub fn save(&self) -> Result<(), ConfigError> { |
no test coverage detected