From b40d325ec88b54a3d86561fe1f052c58d989fb23 Mon Sep 17 00:00:00 2001 From: uncenter <47499684+uncenter@users.noreply.github.com> Date: Sat, 25 May 2024 12:04:10 -0400 Subject: [PATCH] feat(query/has): check for presence of `icon` if booleanish value --- src/main.rs | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index dcf8481..3699d12 100644 --- a/src/main.rs +++ b/src/main.rs @@ -161,7 +161,7 @@ enum Queries { #[arg(long = "category")] categories: Option>, - #[arg(long)] + #[arg(long, num_args = 0..=1, default_missing_value = "true")] icon: Option, #[arg(long)] @@ -296,26 +296,33 @@ fn main() -> Result<()> { } } && { if let Some(icon) = &icon { - if let Some(i) = &userstyle.1.icon { + let i = &userstyle.1.icon; + + (icon == "true" && i.is_some()) + || (icon == "false" && i.is_none()) || (if let Some(i) = i { *icon == *i } else { false - } + }) } else { true } } && { if let Some(color) = &color { - *color == userstyle.1.color + color + .parse() + .unwrap_or_else(|_| *color == userstyle.1.color) } else { true } } && { if let Some(app_link) = &app_link { - match &userstyle.1.readme.app_link { - StringOrStrings::Multiple(l) => l.contains(&app_link), - StringOrStrings::Single(l) => *l == *app_link, - } + app_link.parse().unwrap_or_else(|_| { + match &userstyle.1.readme.app_link { + StringOrStrings::Multiple(l) => l.contains(&app_link), + StringOrStrings::Single(l) => *l == *app_link, + } + }) } else { true }