#![cfg_attr(not(test), warn(clippy::unwrap_used, clippy::expect_used))]
mod actions;
mod cli;
mod config;
mod error;
mod migrate;
mod plugin;
mod report;
mod runtime;
mod script;
use clap::Parser;
use std::process::ExitCode;
fn annotate(message: &str) {
let env = std::env::vars().collect();
let Some(provider) = runtime::ci::detect(&env) else {
return;
};
if let Some(line) = runtime::ci::annotation(provider, "error", message) {
eprintln!("{line}");
}
}
#[cfg(unix)]
fn restore_sigpipe() {
unsafe {
libc::signal(libc::SIGPIPE, libc::SIG_DFL);
}
}
#[cfg(not(unix))]
fn restore_sigpipe() {}
fn main() -> ExitCode {
restore_sigpipe();
match cli::dispatch(cli::Cli::parse()) {
Ok(()) => ExitCode::SUCCESS,
Err(err) => {
eprintln!("error: {err}");
annotate(&err.to_string());
ExitCode::from(err.exit_code() as u8)
}
}
}