Save global configuration to the default location
(&self)
| 1087 | |
| 1088 | /// Save global configuration to the default location |
| 1089 | pub fn save(&self) -> Result<(), ConfigError> { |
| 1090 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 1091 | |
| 1092 | if let Some(parent) = path.parent() { |
| 1093 | std::fs::create_dir_all(parent).map_err(|e| ConfigError::WriteError { |
| 1094 | path: parent.to_path_buf(), |
| 1095 | source: e, |
| 1096 | })?; |
| 1097 | } |
| 1098 | |
| 1099 | let content = toml::to_string_pretty(self)?; |
| 1100 | std::fs::write(&path, content).map_err(|e| ConfigError::WriteError { path, source: e })?; |
| 1101 | |
| 1102 | Ok(()) |
| 1103 | } |
| 1104 | } |
| 1105 | |
| 1106 | impl RepoConfig { |