use anyhow::Result;
use colored::Colorize;
use std::path::PathBuf;
use crate::wg;
pub fn run(paths: &[PathBuf]) -> Result<()> {
let mut all_ok = true;
for path in paths {
let label = path.display();
match std::fs::read_to_string(path) {
Ok(text) => match wg::validate_config(&text) {
Ok(()) => println!("{label}: {}", "ok".green()),
Err(e) => {
all_ok = false;
eprintln!("{label}: {}", e.to_string().red());
}
},
Err(e) => {
all_ok = false;
eprintln!("{label}: {}", format!("can't read: {e}").red());
}
}
}
if !all_ok {
std::process::exit(1);
}
Ok(())
}