Save global configuration to the default location
(&self)
| 457 | |
| 458 | /// Save global configuration to the default location |
| 459 | pub fn save(&self) -> Result<(), ConfigError> { |
| 460 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 461 | |
| 462 | if let Some(parent) = path.parent() { |
| 463 | std::fs::create_dir_all(parent).map_err(|e| ConfigError::WriteError { |
| 464 | path: parent.to_path_buf(), |
| 465 | source: e, |
| 466 | })?; |
| 467 | } |
| 468 | |
| 469 | let content = toml::to_string_pretty(self)?; |
| 470 | std::fs::write(&path, content).map_err(|e| ConfigError::WriteError { path, source: e })?; |
| 471 | |
| 472 | Ok(()) |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | impl RepoConfig { |