From fe4a85f5e31730749d4d90032c2ce60986d79163 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Tue, 14 Oct 2025 07:27:09 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(cli):=20extract?= =?UTF-8?q?=20parameter=20setting=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - move parameter setting into a separate function - create getter functions for struct members --- src/cli/delete_cli.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/cli/delete_cli.rs b/src/cli/delete_cli.rs index 3540130..cb4d6e4 100644 --- a/src/cli/delete_cli.rs +++ b/src/cli/delete_cli.rs @@ -1,5 +1,7 @@ use clap::Parser; -use cull_gmail::{GmailClient, MessageList, Result, RuleProcessor}; +use cull_gmail::{GmailClient, Result, RuleProcessor}; + +use crate::message_trait::Message; /// Command line options for the list subcommand #[derive(Debug, Parser)] @@ -23,18 +25,7 @@ pub struct DeleteCli { impl DeleteCli { pub(crate) async fn run(&self, client: &mut GmailClient) -> Result<()> { - if !self.labels.is_empty() { - // add labels if any specified - client.add_labels(&self.labels).await?; - } - - if let Some(query) = self.query.as_ref() { - client.set_query(query) - } - - log::trace!("Max results: `{}`", self.max_results); - client.set_max_results(self.max_results); - log::debug!("List max results set to {}", client.max_results()); + self.set_parameters(client)?; client.prepare(self.pages).await?; @@ -46,4 +37,16 @@ impl DeleteCli { } Ok(()) } + + pub(crate) fn labels(&self) -> &Vec { + &self.labels + } + + pub(crate) fn query(&self) -> &Option { + &self.query + } + + pub(crate) fn max_results(&self) -> u32 { + self.max_results + } }