From bdf6f56f50621f880cde3c2d025199cd66a90af5 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Fri, 3 Oct 2025 17:36:35 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(labels):=20add=20show=20option?= =?UTF-8?q?=20to=20display=20labels?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add option to show labels when creating a new label - only display labels if show is true --- src/labels.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/labels.rs b/src/labels.rs index 8f2ba22..a936cac 100644 --- a/src/labels.rs +++ b/src/labels.rs @@ -34,7 +34,7 @@ impl std::fmt::Debug for Labels { impl Labels { /// Create a new List struct and add the Gmail api connection. - pub async fn new(credential: &str) -> Result { + pub async fn new(credential: &str, show: bool) -> Result { let (config_dir, secret) = { let config_dir = crate::utils::assure_config_dir_exists("~/.cull-gmail")?; @@ -67,12 +67,14 @@ impl Labels { let call = hub.users().labels_list("me"); let (_response, list) = call.doit().await.map_err(Box::new)?; - if let Some(labels) = &list.labels { - for label in labels { - if let Some(name) = &label.name { - log::info!("{name}"); - } else { - log::warn!("No name for label {:?}", label.id); + if show { + if let Some(labels) = &list.labels { + for label in labels { + if let Some(name) = &label.name { + log::info!("{name}"); + } else { + log::warn!("No name for label {:?}", label.id); + } } } }