♻️ refactor(cli): extract parameter setting logic

- move parameter setting into a separate function
- create getter functions for struct members
This commit is contained in:
Jeremiah Russell
2025-10-14 07:27:09 +01:00
committed by Jeremiah Russell
parent b1fc7f713a
commit fe4a85f5e3

View File

@@ -1,5 +1,7 @@
use clap::Parser; 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 /// Command line options for the list subcommand
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
@@ -23,18 +25,7 @@ pub struct DeleteCli {
impl DeleteCli { impl DeleteCli {
pub(crate) async fn run(&self, client: &mut GmailClient) -> Result<()> { pub(crate) async fn run(&self, client: &mut GmailClient) -> Result<()> {
if !self.labels.is_empty() { self.set_parameters(client)?;
// 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());
client.prepare(self.pages).await?; client.prepare(self.pages).await?;
@@ -46,4 +37,16 @@ impl DeleteCli {
} }
Ok(()) Ok(())
} }
pub(crate) fn labels(&self) -> &Vec<String> {
&self.labels
}
pub(crate) fn query(&self) -> &Option<String> {
&self.query
}
pub(crate) fn max_results(&self) -> u32 {
self.max_results
}
} }