From 008390d08783b1c95e61450defd2009ec04971b5 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 1 Nov 2023 21:28:06 -0500 Subject: [PATCH] keyfork-derive-openpgp: use run-fn style --- keyfork-derive-openpgp/src/main.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/keyfork-derive-openpgp/src/main.rs b/keyfork-derive-openpgp/src/main.rs index ae0ec72..07328f5 100644 --- a/keyfork-derive-openpgp/src/main.rs +++ b/keyfork-derive-openpgp/src/main.rs @@ -1,4 +1,4 @@ -use std::{env, str::FromStr}; +use std::{env, str::FromStr, process::ExitCode}; use keyfork_derive_util::{ request::{DerivationAlgorithm, DerivationRequest}, @@ -97,7 +97,7 @@ fn validate( Ok((path, subkey_format, UserID::from(default_userid))) } -fn main() -> Result<(), Box> { +fn run() -> Result<(), Box> { let mut args = env::args(); let program_name = args.next().expect("program name"); let args = args.collect::>(); @@ -130,3 +130,12 @@ fn main() -> Result<(), Box> { Ok(()) } + +fn main() -> ExitCode { + if let Err(e) = run() { + eprintln!("Error: {e}"); + ExitCode::FAILURE + } else { + ExitCode::SUCCESS + } +}