From c7b71014c2884e0fc9650d1024dc43aef1592f46 Mon Sep 17 00:00:00 2001 From: PThorpe92 Date: Tue, 31 Oct 2023 15:56:25 -0400 Subject: [PATCH] fix: build/tests --- src/options/file_name.rs | 35 ++++++++++++++++------------------- src/output/file_name.rs | 2 +- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/options/file_name.rs b/src/options/file_name.rs index eb68f65d2..6a7930a99 100644 --- a/src/options/file_name.rs +++ b/src/options/file_name.rs @@ -88,29 +88,26 @@ impl ShowIcons { impl QuoteStyle { pub fn deduce(matches: &MatchedFlags<'_>) -> Result { - if let Ok(env) = std::env::var("EZA_QUOTE_STYLE") { - match env.as_str() { - "always" => return Ok(Self::Always), - "never" => return Ok(Self::Never), - &_ => return Ok(Self::Auto), - }; - } else if matches.get(&flags::QUOTES)?.is_some() { - // prioritize the command line flag over the environment variable - let word = matches.get(&flags::QUOTES)?.unwrap(); - match word.to_str() { - Some("always") => return Ok(Self::Always), - Some("never") => return Ok(Self::Never), - Some("auto") => return Ok(Self::Auto), - None => return Err(OptionsError::BadArgument(&flags::QUOTES, word.into())), - _ => return Err(OptionsError::BadArgument(&flags::QUOTES, word.into())), - } - } else { - return Ok(Self::Auto); + let env = std::env::var("EZA_QUOTING_STYLE"); + let env = env.unwrap_or_else(|_| "auto".to_string()); + let env = match env.to_ascii_lowercase().as_str() { + "always" => Self::Always, + "never" => Self::Never, + _ => Self::Auto, }; + if matches.get(&flags::QUOTES)?.is_none() { + Ok(env) + } else { + match matches.get(&flags::QUOTES)?.unwrap() { + word if word.to_str() == Some("always") => Ok(Self::Always), + word if word.to_str() == Some("never") => Ok(Self::Never), + word if word.to_str() == Some("auto") => Ok(Self::Auto), + _ => Err(OptionsError::BadArgument(&flags::QUOTES, "auto".into())), + } + } } } - impl EmbedHyperlinks { fn deduce(matches: &MatchedFlags<'_>) -> Result { let flagged = matches.has(&flags::HYPERLINK)?; diff --git a/src/output/file_name.rs b/src/output/file_name.rs index bd397bdae..d6fb6e191 100644 --- a/src/output/file_name.rs +++ b/src/output/file_name.rs @@ -122,7 +122,7 @@ pub enum EmbedHyperlinks { pub enum QuoteStyle { /// Don't ever quote file names. Never, - /// Quote file names that contain spaces + /// Quote file names that contain spaces (default) Auto, /// Always quote file names. Always,