♻️ 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:
committed by
Jeremiah Russell
parent
d951826c51
commit
2110d56331
@@ -30,11 +30,18 @@ impl RunCli {
|
||||
continue;
|
||||
};
|
||||
|
||||
self.execute_action(processor, action, &label).await;
|
||||
}
|
||||
|
||||
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 {
|
||||
match processor.trash_messages(label).await {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
log::warn!("action failed for label {label} with error {e}");
|
||||
@@ -47,7 +54,7 @@ impl RunCli {
|
||||
EolAction::Delete => {
|
||||
if !self.skip_delete {
|
||||
log::info!("deleting older messages");
|
||||
match processor.delete_messages(&label).await {
|
||||
match processor.delete_messages(label).await {
|
||||
Ok(_) => {}
|
||||
Err(e) => {
|
||||
log::warn!("action failed for label {label} with error {e}");
|
||||
@@ -59,7 +66,4 @@ impl RunCli {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user