From 3a3b972cac7caa9d76eec1bd03829b1e326ee3f5 Mon Sep 17 00:00:00 2001 From: Thorsten Hans Date: Wed, 6 Nov 2024 09:48:08 +0100 Subject: [PATCH] chore: streamlined AppInfo struct and applied review feedback Signed-off-by: Thorsten Hans --- src/commands/apps_output.rs | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/src/commands/apps_output.rs b/src/commands/apps_output.rs index 69f92c8..a61eaf6 100644 --- a/src/commands/apps_output.rs +++ b/src/commands/apps_output.rs @@ -12,8 +12,7 @@ pub(crate) enum OutputFormat { #[derive(Serialize)] pub(crate) struct AppInfo { name: String, - #[serde(skip_serializing_if = "Option::is_none")] - description: Option, + description: String, url: Option, #[serde(rename = "domainInfo")] domain_info: DomainInfo, @@ -34,16 +33,9 @@ impl AppInfo { domain_validation_finished: bool, ) -> Self { let url = domain.as_ref().map(|d| format!("https://{}", d)); - let desc: Option = match description { - Some(d) => match d.is_empty() { - true => None, - false => Some(d), - }, - None => None, - }; Self { name, - description: desc, + description: description.unwrap_or_default(), url, domain_info: DomainInfo { domain, @@ -56,15 +48,10 @@ impl AppInfo { impl Display for AppInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { writeln!(f, "Name: {}", self.name)?; - if self - .description - .as_ref() - .is_some_and(|desc| !desc.is_empty()) - { - writeln!(f, "Description: {}", self.description.clone().unwrap())?; + if !self.description.is_empty() { + writeln!(f, "Description: {}", self.description)?; } - if self.domain_info.domain.is_some() { - let domain = self.domain_info.domain.clone().unwrap(); + if let Some(domain) = self.domain_info.domain.as_ref() { writeln!(f, "URL: https://{}", domain)?; if !self.domain_info.validation_finished { writeln!(f, "Validation for {} is in progress", domain)?;