Load global configuration from the default location
()
| 1071 | impl GlobalConfig { |
| 1072 | /// Load global configuration from the default location |
| 1073 | pub fn load() -> Result<Self, ConfigError> { |
| 1074 | let path = global_config_path().ok_or(ConfigError::NoConfigDir)?; |
| 1075 | |
| 1076 | if !path.exists() { |
| 1077 | return Ok(Self::default()); |
| 1078 | } |
| 1079 | |
| 1080 | let content = std::fs::read_to_string(&path).map_err(|e| ConfigError::ReadError { |
| 1081 | path: path.clone(), |
| 1082 | source: e, |
| 1083 | })?; |
| 1084 | |
| 1085 | Ok(toml::from_str(&content)?) |
| 1086 | } |
| 1087 | |
| 1088 | /// Save global configuration to the default location |
| 1089 | pub fn save(&self) -> Result<(), ConfigError> { |