♻️ refactor(cli): use GmailClient instead of credential file
- use GmailClient to reduce redundant credential file passing
This commit is contained in:
committed by
Jeremiah Russell
parent
88fbf74587
commit
4d452ab5b0
@@ -1,5 +1,5 @@
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cull_gmail::{Error, Trash};
|
use cull_gmail::{Error, GmailClient, Trash};
|
||||||
|
|
||||||
/// Command line options for the list subcommand
|
/// Command line options for the list subcommand
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
@@ -19,14 +19,12 @@ pub struct TrashCli {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TrashCli {
|
impl TrashCli {
|
||||||
pub(crate) async fn run(&self, credential_file: &str) -> Result<(), Error> {
|
pub(crate) async fn run(&self, client: &GmailClient) -> Result<(), Error> {
|
||||||
let mut list = Trash::new(credential_file).await?;
|
let mut list = Trash::new(client).await?;
|
||||||
|
|
||||||
if !self.labels.is_empty() {
|
if !self.labels.is_empty() {
|
||||||
// add labels if any specified
|
// add labels if any specified
|
||||||
list.message_list()
|
list.message_list().add_labels(client, &self.labels).await?;
|
||||||
.add_labels(credential_file, &self.labels)
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(query) = self.query.as_ref() {
|
if let Some(query) = self.query.as_ref() {
|
||||||
|
|||||||
Reference in New Issue
Block a user