From aa1074d4bb87f6dc33adbb0589d48858bbecc973 Mon Sep 17 00:00:00 2001 From: Jeremiah Russell Date: Sun, 12 Oct 2025 07:05:05 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(processor):=20add=20execute=20?= =?UTF-8?q?flag=20for=20dry=20run?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - introduce execute flag to control actual execution of actions - add set_execute method to modify the execute flag - log warning message when execution is stopped for dry run --- src/processor.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/processor.rs b/src/processor.rs index edd6276..9ecb515 100644 --- a/src/processor.rs +++ b/src/processor.rs @@ -25,6 +25,11 @@ impl<'a> Processor<'a> { self.rule.action() } + /// Set the execute flag + pub fn set_execute(&mut self, value: bool) { + self.execute = value + } + /// Trash the messages pub async fn trash_messages(&self, label: &str) -> Result<()> { let mut messages_to_trash = Trash::new(&self.credential_file).await?; @@ -46,9 +51,10 @@ impl<'a> Processor<'a> { log::info!("Ready to run"); messages_to_trash.prepare(0).await?; if self.execute { - log::warn!("***executing final delete messages***"); + log::info!("***executing final delete messages***"); messages_to_trash.batch_trash().await } else { + log::warn!("Execution stopped for dry run"); Ok(()) } } @@ -75,9 +81,11 @@ impl<'a> Processor<'a> { log::info!("Ready to run"); messages_to_delete.prepare(0).await?; if self.execute { - log::warn!("***executing final delete messages***"); + log::info!("***executing final delete messages***"); messages_to_delete.batch_delete().await } else { + log::warn!("Execution stopped for dry run"); + Ok(()) } }