Save global configuration to the default location
(&self)
| 395 | |
| 396 | /// Save global configuration to the default location |
| 397 | pub fn save(&self) -> Result<(), ConfigError> { |
| 398 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 399 | |
| 400 | if let Some(parent) = path.parent() { |
| 401 | std::fs::create_dir_all(parent).map_err(|e| ConfigError::WriteError { |
| 402 | path: parent.to_path_buf(), |
| 403 | source: e, |
| 404 | })?; |
| 405 | } |
| 406 | |
| 407 | let content = toml::to_string_pretty(self)?; |
| 408 | std::fs::write(&path, content).map_err(|e| ConfigError::WriteError { path, source: e })?; |
| 409 | |
| 410 | Ok(()) |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | impl RepoConfig { |