refactor new backend api

This commit is contained in:
Clément DOUIN
2024-01-27 11:15:03 +01:00
parent 16266dbc0b
commit 4f9705952a
37 changed files with 819 additions and 1897 deletions
+3 -37
View File
@@ -1,15 +1,7 @@
use anyhow::Result;
use clap::Parser;
#[cfg(feature = "imap")]
use email::folder::add::imap::AddImapFolder;
#[cfg(feature = "maildir")]
use email::folder::add::maildir::AddMaildirFolder;
#[cfg(feature = "notmuch")]
use email::folder::add::notmuch::AddNotmuchFolder;
use log::info;
#[cfg(any(feature = "imap", feature = "maildir", feature = "account-sync"))]
use crate::backend::BackendKind;
#[cfg(feature = "account-sync")]
use crate::cache::arg::disable::CacheDisableFlag;
use crate::{
@@ -48,36 +40,10 @@ impl AddFolderCommand {
let add_folder_kind = toml_account_config.add_folder_kind();
let backend = Backend::new(
&toml_account_config,
&account_config,
toml_account_config.clone(),
account_config,
add_folder_kind,
|builder| match add_folder_kind {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder.set_add_folder(|ctx| ctx.imap.as_ref().map(AddImapFolder::new_boxed));
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder.set_add_folder(|ctx| {
ctx.maildir.as_ref().map(AddMaildirFolder::new_boxed)
});
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_add_folder(|ctx| {
ctx.maildir_for_sync
.as_ref()
.map(AddMaildirFolder::new_boxed)
});
}
#[cfg(feature = "notmuch")]
Some(BackendKind::Notmuch) => {
builder.set_add_folder(|ctx| {
ctx.notmuch.as_ref().map(AddNotmuchFolder::new_boxed)
});
}
_ => (),
},
|builder| builder.set_add_folder(Some(None)),
)
.await?;