keyfork-derive-openpgp: use run-fn style

This commit is contained in:
Ryan Heywood 2023-11-01 21:28:06 -05:00
parent bc5bd8a7b9
commit 008390d087
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 11 additions and 2 deletions

View File

@ -1,4 +1,4 @@
use std::{env, str::FromStr}; use std::{env, str::FromStr, process::ExitCode};
use keyfork_derive_util::{ use keyfork_derive_util::{
request::{DerivationAlgorithm, DerivationRequest}, request::{DerivationAlgorithm, DerivationRequest},
@ -97,7 +97,7 @@ fn validate(
Ok((path, subkey_format, UserID::from(default_userid))) Ok((path, subkey_format, UserID::from(default_userid)))
} }
fn main() -> Result<(), Box<dyn std::error::Error>> { fn run() -> Result<(), Box<dyn std::error::Error>> {
let mut args = env::args(); let mut args = env::args();
let program_name = args.next().expect("program name"); let program_name = args.next().expect("program name");
let args = args.collect::<Vec<_>>(); let args = args.collect::<Vec<_>>();
@ -130,3 +130,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(()) Ok(())
} }
fn main() -> ExitCode {
if let Err(e) = run() {
eprintln!("Error: {e}");
ExitCode::FAILURE
} else {
ExitCode::SUCCESS
}
}