From 1997fd21424c8776917e7f8fc9efef419f2b5c75 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Sat, 11 Oct 2025 07:37:15 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(cli):=20add=20option=20to=20sk?= =?UTF-8?q?ip=20trash=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - introduce `--skip-trash` flag to prevent trashing messages - add warning log when a trash action is skipped due to the flag --- src/cli/run_cli.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cli/run_cli.rs b/src/cli/run_cli.rs index 5674f26..928b0f9 100644 --- a/src/cli/run_cli.rs +++ b/src/cli/run_cli.rs @@ -2,7 +2,11 @@ use clap::Parser; use cull_gmail::{Config, EolAction, Processor, Result}; #[derive(Debug, Parser)] -pub struct RunCli {} +pub struct RunCli { + /// Skip any rules that apply the action `trash` + #[clap(short = 't', long)] + skip_trash: bool, +} impl RunCli { pub async fn run(&self, config: Config) -> Result<()> { @@ -25,12 +29,16 @@ impl RunCli { match action { EolAction::Trash => { - log::info!("trashing older messages"); - match processor.trash_messages(&label).await { - Ok(_) => {} - Err(e) => { - log::warn!("action failed for label {label} with error {e}"); + if !self.skip_trash { + log::info!("trashing older messages"); + match processor.trash_messages(&label).await { + Ok(_) => {} + Err(e) => { + log::warn!("action failed for label {label} with error {e}"); + } } + } else { + log::warn!("Rule with `trash` action for label `{label}` skipped."); } } EolAction::Delete => {