Skip to content

Commit

Permalink
feat: Report existance of issues with exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
VorpalBlade committed Feb 26, 2024
1 parent 97db314 commit 99b7bb7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/paketkoll/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
11 changes: 9 additions & 2 deletions crates/paketkoll/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exit> {
let mut builder =
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("warn"));
builder.init();
Expand All @@ -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()))
Expand All @@ -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<Backend> for paketkoll_core::config::Backend {
Expand Down

0 comments on commit 99b7bb7

Please sign in to comment.