Load configuration
()
| 144 | |
| 145 | /// Load configuration |
| 146 | pub fn load() -> Result<Self> { |
| 147 | let config_path = Self::config_path()?; |
| 148 | |
| 149 | if !config_path.exists() { |
| 150 | tracing::info!("Config file not found, using defaults"); |
| 151 | let config = Self::default(); |
| 152 | config.save()?; |
| 153 | return Ok(config); |
| 154 | } |
| 155 | |
| 156 | let content = fs::read_to_string(&config_path)?; |
| 157 | let config: Self = toml::from_str(&content)?; |
| 158 | tracing::info!("Loaded config: {:?}", config_path); |
| 159 | Ok(config) |
| 160 | } |
| 161 | |
| 162 | /// Save configuration |
| 163 | pub fn save(&self) -> Result<()> { |
no test coverage detected