From 58de6397ced43d74229e3bff083ba2c95f3464b5 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Fri, 3 Oct 2025 16:37:35 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(list):=20add=20label=20filteri?= =?UTF-8?q?ng=20to=20list=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - allow users to filter tasks by label when listing tasks - refactor label handling to support multiple labels --- src/list_cli.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/list_cli.rs b/src/list_cli.rs index 11c3e4a..1f0d2f1 100644 --- a/src/list_cli.rs +++ b/src/list_cli.rs @@ -17,18 +17,21 @@ pub struct ListCli { impl ListCli { pub(crate) async fn run(&self, credential_file: &str) -> Result<(), Error> { - let mut labels = Labels::new(credential_file).await?; - labels.get_labels().await?; - log::trace!("labels found and setup {labels:#?}"); - let mut list = List::new(credential_file).await?; - log::debug!("labels from command line: {:?}", self.labels); - for label in &self.labels { - if let Some(l) = labels.get_label_id(label) { - log::trace!("adding `{l}` id to labels"); - list.add_label(&l); + if !self.labels.is_empty() { + // add labels if any specified + let label_list = Labels::new(credential_file).await?; + + log::trace!("labels found and setup {label_list:#?}"); + log::debug!("labels from command line: {:?}", self.labels); + let mut label_ids = Vec::new(); + for label in &self.labels { + if let Some(id) = label_list.get_label_id(label) { + label_ids.push(id) + } } + list.add_labels(label_ids.as_slice()); } log::trace!("Max results: `{}`", self.max_results);