use anyhow::Result;
use serde::Deserialize;
use std::path::Path;
#[derive(Debug, Default, Deserialize)]
pub struct SvccatConfig {
pub format: Option<String>,
#[serde(default)]
pub fail_on_drift: bool,
#[serde(default)]
pub ignore: Vec<String>,
}
impl SvccatConfig {
pub fn load(root: &Path) -> Result<Self> {
let path = root.join("svccat.toml");
if !path.exists() {
return Ok(Self::default());
}
let text = std::fs::read_to_string(&path)
.map_err(|e| anyhow::anyhow!("cannot read svccat.toml: {e}"))?;
let cfg: Self =
toml::from_str(&text).map_err(|e| anyhow::anyhow!("cannot parse svccat.toml: {e}"))?;
Ok(cfg)
}
}