Save global configuration to the default location
(&self)
| 377 | |
| 378 | /// Save global configuration to the default location |
| 379 | pub fn save(&self) -> Result<(), ConfigError> { |
| 380 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 381 | |
| 382 | if let Some(parent) = path.parent() { |
| 383 | std::fs::create_dir_all(parent).map_err(|e| ConfigError::WriteError { |
| 384 | path: parent.to_path_buf(), |
| 385 | source: e, |
| 386 | })?; |
| 387 | } |
| 388 | |
| 389 | let content = toml::to_string_pretty(self)?; |
| 390 | std::fs::write(&path, content).map_err(|e| ConfigError::WriteError { path, source: e })?; |
| 391 | |
| 392 | Ok(()) |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | impl RepoConfig { |