♻️ 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:
committed by
Jeremiah Russell
parent
04478a13f8
commit
22e1916262
@@ -1,5 +1,5 @@
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cull_gmail::{Delete, Result};
|
use cull_gmail::{Delete, GmailClient, Result};
|
||||||
|
|
||||||
/// Command line options for the list subcommand
|
/// Command line options for the list subcommand
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
@@ -22,14 +22,14 @@ pub struct DeleteCli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl DeleteCli {
|
impl DeleteCli {
|
||||||
pub(crate) async fn run(&self, credential_file: &str) -> Result<()> {
|
pub(crate) async fn run(&self, client: &GmailClient) -> Result<()> {
|
||||||
let mut messages_to_delete = Delete::new(credential_file).await?;
|
let mut messages_to_delete = Delete::new(client).await?;
|
||||||
|
|
||||||
if !self.labels.is_empty() {
|
if !self.labels.is_empty() {
|
||||||
// add labels if any specified
|
// add labels if any specified
|
||||||
messages_to_delete
|
messages_to_delete
|
||||||
.message_list()
|
.message_list()
|
||||||
.add_labels(credential_file, &self.labels)
|
.add_labels(client, &self.labels)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user