use anyhow::Result;
use directories::ProjectDirs;
use serde::Deserialize;
use std::{fs, path::PathBuf};
#[derive(Debug, Deserialize, Default, Clone)]
pub struct Config {
#[serde(default)]
pub exclude_prefixes: Vec<PathBuf>,
}
pub fn load_config() -> Result<Config> {
let proj = ProjectDirs::from("dev", "cleanux", "cleanux")
.expect("could not determine config directory");
let cfg_path = proj.config_dir().join("config.toml");
if !cfg_path.exists() {
return Ok(Config::default());
}
let txt = fs::read_to_string(cfg_path)?;
Ok(toml::from_str(&txt)?)
}