From ae4ebcff7934feec8c72d81be352b5ed6decc770 Mon Sep 17 00:00:00 2001 From: garikello3d Date: Mon, 25 Dec 2023 12:27:03 +0100 Subject: [PATCH] return exit code the proper way --- src/bin/bigarchiver/main.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/bin/bigarchiver/main.rs b/src/bin/bigarchiver/main.rs index 173846b..ddecbf2 100644 --- a/src/bin/bigarchiver/main.rs +++ b/src/bin/bigarchiver/main.rs @@ -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; @@ -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 }