diff --git a/Cargo.lock b/Cargo.lock index 80c2699b..db8b4ac4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -582,6 +582,7 @@ dependencies = [ "log", "os_info", "paketkoll_core", + "proc-exit", ] [[package]] @@ -676,6 +677,12 @@ dependencies = [ "yansi", ] +[[package]] +name = "proc-exit" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbd05acff31c8b626109e8e1db042b9bddb2b3ffba01ead93d15b78517a282ca" + [[package]] name = "proc-macro2" version = "1.0.78" diff --git a/crates/paketkoll/Cargo.toml b/crates/paketkoll/Cargo.toml index 5b4eb9e3..7453933e 100644 --- a/crates/paketkoll/Cargo.toml +++ b/crates/paketkoll/Cargo.toml @@ -25,6 +25,7 @@ env_logger = "0.11.2" log = "0.4.20" os_info = { version = "3.7.0", default-features = false } paketkoll_core = { version = "0.1.1", path = "../paketkoll_core" } +proc-exit = "2.0.1" [build-dependencies] clap = { version = "4.5.1", features = ["derive"] } diff --git a/crates/paketkoll/src/main.rs b/crates/paketkoll/src/main.rs index 5abb1095..c6a58a14 100644 --- a/crates/paketkoll/src/main.rs +++ b/crates/paketkoll/src/main.rs @@ -5,8 +5,9 @@ mod cli; use clap::Parser; use cli::{Backend, Cli}; use paketkoll_core::{backend, config}; +use proc_exit::{Code, Exit}; -fn main() -> anyhow::Result<()> { +fn main() -> anyhow::Result { let mut builder = env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn")); builder.init(); @@ -22,6 +23,8 @@ fn main() -> anyhow::Result<()> { ) }); + let has_issues = !found_issues.is_empty(); + for (pkg, issue) in found_issues.into_iter() { let pkg = pkg .and_then(|e| interner.try_resolve(&e.as_interner_ref())) @@ -30,7 +33,11 @@ fn main() -> anyhow::Result<()> { println!("{pkg}: {:?} {kind}", issue.path()); } } - Ok(()) + Ok(if has_issues { + Exit::new(Code::FAILURE) + } else { + Exit::new(Code::SUCCESS) + }) } impl TryFrom for paketkoll_core::config::Backend {