From 0773529ba578b94389b307e327de486305afa83e Mon Sep 17 00:00:00 2001 From: Valerie Date: Thu, 21 Nov 2024 08:18:09 -0500 Subject: [PATCH] default flag behavior now correctly handles empty variable --- src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index dbd043d..16b05f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,7 +51,12 @@ fn main() { let state = State::new(&mut args); - let subcommand = if let Ok(Some(subcommand)) = args.subcommand() { Some(subcommand) } else { var("PRIDE_DEFAULT").ok() }; + let subcommand = + if let Ok(Some(subcommand)) = args.subcommand() { Some(subcommand) } + else if let Ok(default) = var("PRIDE_DEFAULT") { + if default.is_empty() { None } + else { Some(default) } + } else { None }; let variant = args.subcommand().unwrap(); // get color vec from matched flag