From ca06e9290f5d3aa56268ab8142e42dfac5bb176b Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Thu, 9 Oct 2025 16:38:55 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(message):=20add=20label=20supp?= =?UTF-8?q?ort=20to=20message=20listing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add ability to filter messages by labels - enhance message listing functionality --- src/cli/message_cli.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/src/cli/message_cli.rs b/src/cli/message_cli.rs index f710971..6ac9bea 100644 --- a/src/cli/message_cli.rs +++ b/src/cli/message_cli.rs @@ -1,5 +1,5 @@ use clap::Parser; -use cull_gmail::{Error, Labels, MessageList}; +use cull_gmail::{MessageList, Result}; /// Command line options for the list subcommand #[derive(Debug, Parser)] @@ -19,22 +19,11 @@ pub struct MessageCli { } impl MessageCli { - pub(crate) async fn run(&self, credential_file: &str) -> Result<(), Error> { + pub(crate) async fn run(&self, credential_file: &str) -> Result<()> { let mut list = MessageList::new(credential_file).await?; 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() {