♻️ refactor(cli): use GmailClient in delete_cli

- use GmailClient struct instead of credential_file path
- simplifies client handling and avoids redundant credential loading
This commit is contained in:
Jeremiah Russell
2025-10-13 13:53:38 +01:00
committed by Jeremiah Russell
parent 04478a13f8
commit 22e1916262

View File

@@ -1,5 +1,5 @@
use clap::Parser;
use cull_gmail::{Delete, Result};
use cull_gmail::{Delete, GmailClient, Result};
/// Command line options for the list subcommand
#[derive(Debug, Parser)]
@@ -22,14 +22,14 @@ pub struct DeleteCli {
}
impl DeleteCli {
pub(crate) async fn run(&self, credential_file: &str) -> Result<()> {
let mut messages_to_delete = Delete::new(credential_file).await?;
pub(crate) async fn run(&self, client: &GmailClient) -> Result<()> {
let mut messages_to_delete = Delete::new(client).await?;
if !self.labels.is_empty() {
// add labels if any specified
messages_to_delete
.message_list()
.add_labels(credential_file, &self.labels)
.add_labels(client, &self.labels)
.await?;
}