diff --git a/src/cli/main.rs b/src/cli/main.rs index b2e38bc..7326fd9 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -136,22 +136,7 @@ async fn run_rules(client: &mut GmailClient, rules: Rules, execute: bool) -> Res }; if execute { - match action { - EolAction::Trash => { - log::info!("***executing trash messages***"); - if client.batch_trash().await.is_err() { - log::warn!("Move to trash failed for label `{label}`"); - continue; - } - } - EolAction::Delete => { - log::info!("***executing final delete messages***"); - if client.batch_delete().await.is_err() { - log::warn!("Delete failed for label `{label}`"); - continue; - } - } - } + execute_action(action, client, &label).await; } else { log::warn!("Execution stopped for dry run"); } @@ -159,3 +144,20 @@ async fn run_rules(client: &mut GmailClient, rules: Rules, execute: bool) -> Res Ok(()) } + +async fn execute_action(action: EolAction, client: &GmailClient, label: &str) { + match action { + EolAction::Trash => { + log::info!("***executing trash messages***"); + if client.batch_trash().await.is_err() { + log::warn!("Move to trash failed for label `{label}`"); + } + } + EolAction::Delete => { + log::info!("***executing final delete messages***"); + if client.batch_delete().await.is_err() { + log::warn!("Delete failed for label `{label}`"); + } + } + } +}