From b442232cf92325e88d0ae4b7670918fc5d9fe9de Mon Sep 17 00:00:00 2001 From: Hatter Jiang Date: Fri, 5 Aug 2022 22:29:27 +0800 Subject: [PATCH] feat: returns error code --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cmd_chall.rs | 1 + src/main.rs | 6 ++++-- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 005562e..0280b33 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -376,7 +376,7 @@ dependencies = [ [[package]] name = "card-cli" -version = "1.4.0" +version = "1.4.1" dependencies = [ "authenticator", "base64 0.13.0", diff --git a/Cargo.toml b/Cargo.toml index 8f0e369..d481a69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "card-cli" -version = "1.4.0" +version = "1.4.1" authors = ["Hatter Jiang "] edition = "2018" diff --git a/src/cmd_chall.rs b/src/cmd_chall.rs index 4a4f134..0d87836 100644 --- a/src/cmd_chall.rs +++ b/src/cmd_chall.rs @@ -85,6 +85,7 @@ impl Command for CommandImpl { } } else { warning!("YubiKey not found"); + return Ok(Some(1)); } Ok(None) diff --git a/src/main.rs b/src/main.rs index 74f8eb1..bd3db3a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,8 +44,10 @@ impl DefaultCommandImpl { } fn main() { - if let Err(e) = inner_main() { - failure_and_exit!("Run cli error: {}", e); + match inner_main() { + Err(e) => failure_and_exit!("Run cli error: {}", e), + Ok(Some(code)) => std::process::exit(code), + Ok(None) => (), } }