From fdf623ea2088546e6e49428edc2da648f9583e65 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Thu, 9 Oct 2025 16:39:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(trash):=20streaml?= =?UTF-8?q?ine=20label=20handling=20in=20trash=20listing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - consolidate label retrieval and addition into `add_labels` method - improve code clarity and reduce redundancy --- src/cli/trash_cli.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/cli/trash_cli.rs b/src/cli/trash_cli.rs index 238e6cd..89cdd9c 100644 --- a/src/cli/trash_cli.rs +++ b/src/cli/trash_cli.rs @@ -1,5 +1,5 @@ use clap::Parser; -use cull_gmail::{Error, Labels, Trash}; +use cull_gmail::{Error, Trash}; /// Command line options for the list subcommand #[derive(Debug, Parser)] @@ -24,17 +24,7 @@ impl TrashCli { if !self.labels.is_empty() { // add labels if any specified - let label_list = Labels::new(credential_file, false).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()); + list.add_labels(credential_file, &self.labels).await?; } if let Some(query) = self.query.as_ref() {