1use std::io;
11use std::path::Path;
12
13pub const FILE_NAME: &str = ".just-shield.conf";
14
15#[derive(Default)]
16pub struct Config {
17 pub trusted_owners: Vec<String>,
19 pub cooldown_days: Option<u32>,
21}
22
23pub fn load(root: &Path) -> io::Result<Config> {
25 let path = root.join(FILE_NAME);
26 if !path.is_file() {
27 return Ok(Config::default());
28 }
29 let content = std::fs::read_to_string(path)?;
30 let mut config = Config::default();
31 for line in content.lines() {
32 let line = line.trim();
33 if line.is_empty() || line.starts_with('#') {
34 continue;
35 }
36 if let Some(owner) = line.strip_prefix("trust-org") {
37 let owner = owner.trim();
38 if !owner.is_empty() {
39 config.trusted_owners.push(owner.to_string());
40 }
41 } else if let Some(days) = line.strip_prefix("cooldown-days") {
42 config.cooldown_days = days.trim().parse().ok();
43 }
44 }
46 Ok(config)
47}