feat(xatu): set CLI exit statuses #80

Merged
alexion merged 1 commits from feat/xatu-cli-exit-status into main 2026-09-19 17:07:12 -04:00
Showing only changes of commit 87dc93513b - Show all commits

View File

@@ -1,7 +1,8 @@
use clap::Parser;
use status::ResultExt;
use std::path::{Path, PathBuf};
use xatu::SourceFile;
use std::process::ExitCode;
use xatu::{Report, SourceFile};
fn is_nix_file(path: &Path) -> bool {
path.extension().is_some_and(|extension| extension == "nix")
@@ -66,9 +67,7 @@ struct Args {
paths: Vec<PathBuf>,
}
fn main() -> status::Result<()> {
let args = Args::parse();
fn analyze(args: Args) -> status::Result<Report> {
let paths: Vec<PathBuf> = args
.paths
.into_iter()
@@ -83,8 +82,22 @@ fn main() -> status::Result<()> {
.flatten()
.collect();
let report = xatu::future_sight(files)?;
print!("{report}");
Ok(())
xatu::future_sight(files)
}
fn main() -> ExitCode {
match analyze(Args::parse()) {
Ok(report) if report.is_clean() => {
println!("No findings.");
ExitCode::SUCCESS
}
Ok(report) => {
print!("{report}");
ExitCode::from(1)
}
Err(error) => {
eprintln!("{error}");
ExitCode::from(2)
}
}
}