use std::io;
use std::path::Path;
pub const FILE_NAME: &str = ".just-shield.conf";
#[derive(Default)]
pub struct Config {
pub trusted_owners: Vec<String>,
pub cooldown_days: Option<u32>,
}
pub fn load(root: &Path) -> io::Result<Config> {
let path = root.join(FILE_NAME);
if !path.is_file() {
return Ok(Config::default());
}
let content = std::fs::read_to_string(path)?;
let mut config = Config::default();
for line in content.lines() {
let line = line.trim();
if line.is_empty() || line.starts_with('#') {
continue;
}
if let Some(owner) = line.strip_prefix("trust-org") {
let owner = owner.trim();
if !owner.is_empty() {
config.trusted_owners.push(owner.to_string());
}
} else if let Some(days) = line.strip_prefix("cooldown-days") {
config.cooldown_days = days.trim().parse().ok();
}
}
Ok(config)
}