Save global configuration to the default location
(&self)
| 470 | |
| 471 | /// Save global configuration to the default location |
| 472 | pub fn save(&self) -> Result<(), ConfigError> { |
| 473 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 474 | |
| 475 | if let Some(parent) = path.parent() { |
| 476 | std::fs::create_dir_all(parent).map_err(|e| ConfigError::WriteError { |
| 477 | path: parent.to_path_buf(), |
| 478 | source: e, |
| 479 | })?; |
| 480 | } |
| 481 | |
| 482 | let content = toml::to_string_pretty(self)?; |
| 483 | std::fs::write(&path, content).map_err(|e| ConfigError::WriteError { path, source: e })?; |
| 484 | |
| 485 | Ok(()) |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | impl RepoConfig { |