Skip to content

Commit

Permalink
return exit code the proper way
Browse files Browse the repository at this point in the history
  • Loading branch information
garikello3d committed Dec 25, 2023
1 parent 7bbcefc commit ae4ebcf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/bin/bigarchiver/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use bigarchiver::{backup, check};
use bigarchiver::file_set::cfg_from_pattern;
use bigarchiver::finalizable::DataSink;
use std::io::{stdout, Write};
use std::process::ExitCode;

struct StdoutWriter;

Expand Down Expand Up @@ -55,21 +56,21 @@ fn process_args(args: &ArgOpts) -> Result<(), String> {
}
}

fn main() {
fn main() -> ExitCode {
let args = {
let args = ArgOpts::from_os_args(&std::env::args_os().skip(1).collect());
if let Err((err_msg, usage)) = &args {
eprintln!("{}\n\n{}", err_msg, usage);
std::process::exit(1);
return ExitCode::from(2);
};
args.unwrap()
};

if let Err(e) = process_args(&args) {
eprintln!("\nerror: {}\n", e);
// TODO set proper exit code
return ExitCode::from(1);
} else {
eprintln!("\ndone\n");
}

ExitCode::SUCCESS
}

0 comments on commit ae4ebcf

Please sign in to comment.