♻️ refactor(cli): extract action execution to separate function

- move action execution logic into its own function
- improve readability and maintainability
This commit is contained in:
Jeremiah Russell
2025-10-11 09:30:29 +01:00
committed by Jeremiah Russell
parent d951826c51
commit 2110d56331

View File

@@ -30,36 +30,40 @@ impl RunCli {
continue; continue;
}; };
match action { self.execute_action(processor, action, &label).await;
EolAction::Trash => {
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 => {
if !self.skip_delete {
log::info!("deleting older messages");
match processor.delete_messages(&label).await {
Ok(_) => {}
Err(e) => {
log::warn!("action failed for label {label} with error {e}");
}
}
} else {
log::warn!("Rule with `delete` action for label `{label}` skipped.");
}
}
}
} }
Ok(()) Ok(())
} }
async fn execute_action<'a>(&self, processor: Processor<'a>, action: EolAction, label: &str) {
match action {
EolAction::Trash => {
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 => {
if !self.skip_delete {
log::info!("deleting older messages");
match processor.delete_messages(label).await {
Ok(_) => {}
Err(e) => {
log::warn!("action failed for label {label} with error {e}");
}
}
} else {
log::warn!("Rule with `delete` action for label `{label}` skipped.");
}
}
}
}
} }