mod args;
mod load;
mod run;
use std::process::ExitCode;
use clap::Parser;
use args::{Cli, Command};
fn main() -> ExitCode {
let cli = Cli::parse();
let result = match cli.command {
Command::Run {
path,
data,
format,
fail_fast,
} => run::run(&path, &data, format, fail_fast).map(|failed| {
if failed == 0 {
ExitCode::SUCCESS
} else {
ExitCode::FAILURE
}
}),
Command::Bless { path, data } => run::bless(&path, &data).map(|()| ExitCode::SUCCESS),
Command::List { path } => run::list(&path).map(|()| ExitCode::SUCCESS),
Command::Version => {
println!("{}", wickra_strategy_ci_core::VERSION);
Ok(ExitCode::SUCCESS)
}
};
match result {
Ok(code) => code,
Err(message) => {
eprintln!("error: {message}");
ExitCode::FAILURE
}
}
}