feat(cli): add option to skip trash actions

- introduce `--skip-trash` flag to prevent trashing messages
- add warning log when a trash action is skipped due to the flag
This commit is contained in:
Jeremiah Russell
2025-10-11 07:37:15 +01:00
committed by Jeremiah Russell
parent 81157e6ce9
commit 1997fd2142

View File

@@ -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,6 +29,7 @@ impl RunCli {
match action {
EolAction::Trash => {
if !self.skip_trash {
log::info!("trashing older messages");
match processor.trash_messages(&label).await {
Ok(_) => {}
@@ -32,6 +37,9 @@ impl RunCli {
log::warn!("action failed for label {label} with error {e}");
}
}
} else {
log::warn!("Rule with `trash` action for label `{label}` skipped.");
}
}
EolAction::Delete => {
log::info!("deleting older messages");