wip: use shared stuff from pimalaya-tui

This commit is contained in:
Clément DOUIN
2024-10-16 11:46:12 +02:00
parent 2386d0f517
commit a0dea19cdf
70 changed files with 708 additions and 4055 deletions
+19 -12
View File
@@ -1,12 +1,17 @@
use std::sync::Arc;
use clap::Parser;
use color_eyre::Result;
use email::backend::feature::BackendFeatureSource;
use pimalaya_tui::{
himalaya::backend::BackendBuilder,
terminal::{cli::printer::Printer, config::TomlConfig as _},
};
use tracing::info;
use crate::{
account::arg::name::AccountNameFlag, backend::Backend, config::Config,
envelope::arg::ids::EnvelopeIdsArgs, folder::arg::name::FolderNameOptionalFlag,
printer::Printer,
account::arg::name::AccountNameFlag, config::TomlConfig, envelope::arg::ids::EnvelopeIdsArgs,
folder::arg::name::FolderNameOptionalFlag,
};
/// Mark as deleted a message from a folder.
@@ -28,7 +33,7 @@ pub struct MessageDeleteCommand {
}
impl MessageDeleteCommand {
pub async fn execute(self, printer: &mut impl Printer, config: &Config) -> Result<()> {
pub async fn execute(self, printer: &mut impl Printer, config: &TomlConfig) -> Result<()> {
info!("executing delete message(s) command");
let folder = &self.folder.name;
@@ -38,18 +43,20 @@ impl MessageDeleteCommand {
.clone()
.into_account_configs(self.account.name.as_deref())?;
let delete_messages_kind = toml_account_config.delete_messages_kind();
let backend = Backend::new(
toml_account_config.clone(),
account_config,
delete_messages_kind,
|builder| builder.set_delete_messages(BackendFeatureSource::Context),
let backend = BackendBuilder::new(
Arc::new(toml_account_config),
Arc::new(account_config),
|builder| {
builder
.without_features()
.with_delete_messages(BackendFeatureSource::Context)
},
)
.build()
.await?;
backend.delete_messages(folder, ids).await?;
printer.out(format!("Message(s) successfully removed from {folder}!"))
printer.out(format!("Message(s) successfully removed from {folder}!\n"))
}
}