use std::path::{Path, PathBuf};
use snipdoc::{cli::CmdExit, config::Config};
use super::{super::Format, run::run};
pub fn exec(config: &Config, inject_folder: &Path, db_file: Option<PathBuf>) -> CmdExit {
let span = tracing::span!(tracing::Level::INFO, "checks");
let _guard = span.enter();
let injector = match run(config, inject_folder, db_file) {
Ok(i) => i,
Err(err) => {
return CmdExit::error_with_message(&format!("could not init walk instance: {err}"));
}
};
let stats = injector.results.stats();
Format::Console.reporter().check(inject_folder, &stats);
if !stats.errors.is_empty() || stats.injects > 0 || stats.not_found_count > 0 {
CmdExit::error()
} else {
CmdExit::ok()
}
}