git_atomic/cli/commands/
validate.rs1use crate::cli::output::Printer;
2use crate::config::layered;
3use crate::core::Error;
4use std::path::Path;
5
6pub fn run(config_path: &Path, printer: &Printer) -> Result<(), Error> {
7 let repo =
9 crate::git::open_repo(&std::env::current_dir().map_err(|e| Error::General(e.to_string()))?)
10 .ok();
11
12 match crate::config::load_layered_config(repo.as_ref(), config_path) {
13 Ok(resolved) => {
14 let warnings = layered::validate_resolved(&resolved);
15 for w in &warnings {
16 printer.print_config_warning(w);
17 }
18 printer.print_validate_ok();
19 Ok(())
20 }
21 Err(e) => {
22 let err = Error::Config(e);
23 printer.print_validate_error(&err);
24 Err(err)
25 }
26 }
27}