Skip to content

Commit

Permalink
add back notmuch features (part 1)
Browse files Browse the repository at this point in the history
  • Loading branch information
soywod committed Jan 21, 2024
1 parent a700f35 commit 3137e1e
Show file tree
Hide file tree
Showing 30 changed files with 456 additions and 309 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/account/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use email::account::sync::config::SyncConfig;
use email::imap::config::ImapConfig;
#[cfg(feature = "maildir")]
use email::maildir::config::MaildirConfig;
#[cfg(feature = "notmuch")]
use email::notmuch::config::NotmuchConfig;
#[cfg(feature = "sendmail")]
use email::sendmail::config::SendmailConfig;
#[cfg(feature = "smtp")]
Expand Down
287 changes: 163 additions & 124 deletions src/backend/mod.rs

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions src/email/envelope/command/list.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use clap::Parser;
#[cfg(feature = "imap")]
use email::envelope::list::imap::ListEnvelopesImap;
use email::envelope::list::imap::ListImapEnvelopes;
#[cfg(feature = "maildir")]
use email::envelope::list::maildir::ListEnvelopesMaildir;
use email::envelope::list::maildir::ListMaildirEnvelopes;
#[cfg(feature = "notmuch")]
use email::envelope::list::notmuch::ListEnvelopesNotmuch;
use email::envelope::list::notmuch::ListNotmuchEnvelopes;
use log::info;

#[cfg(feature = "account-sync")]
Expand Down Expand Up @@ -92,21 +92,27 @@ impl ListEnvelopesCommand {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder.set_list_envelopes(|ctx| {
ctx.imap.as_ref().and_then(ListEnvelopesImap::new)
ctx.imap.as_ref().map(ListImapEnvelopes::new_boxed)
});
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder.set_list_envelopes(|ctx| {
ctx.maildir.as_ref().and_then(ListEnvelopesMaildir::new)
ctx.maildir.as_ref().map(ListMaildirEnvelopes::new_boxed)
});
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_list_envelopes(|ctx| {
ctx.maildir_for_sync
.as_ref()
.and_then(ListEnvelopesMaildir::new)
.map(ListMaildirEnvelopes::new_boxed)
});
}
#[cfg(feature = "notmuch")]
Some(BackendKind::Notmuch) => {
builder.set_list_envelopes(|ctx| {
ctx.notmuch.as_ref().map(ListNotmuchEnvelopes::new_boxed)
});
}
_ => (),
Expand Down
17 changes: 12 additions & 5 deletions src/email/envelope/command/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use clap::Parser;
use email::envelope::watch::imap::WatchImapEnvelopes;
#[cfg(feature = "maildir")]
use email::envelope::watch::maildir::WatchMaildirEnvelopes;
#[cfg(feature = "notmuch")]
use email::envelope::watch::notmuch::WatchNotmuchEnvelopes;
// #[cfg(feature = "notmuch")]
// use email::envelope::watch::notmuch::WatchNotmuchEnvelopes;
use log::info;

#[cfg(feature = "account-sync")]
Expand Down Expand Up @@ -56,23 +56,30 @@ impl WatchEnvelopesCommand {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder.set_watch_envelopes(|ctx| {
ctx.imap.as_ref().and_then(WatchImapEnvelopes::new)
ctx.imap.as_ref().map(WatchImapEnvelopes::new_boxed)
});
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder.set_watch_envelopes(|ctx| {
ctx.maildir.as_ref().and_then(WatchMaildirEnvelopes::new)
ctx.maildir.as_ref().map(WatchMaildirEnvelopes::new_boxed)
});
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_watch_envelopes(|ctx| {
ctx.maildir_for_sync
.as_ref()
.and_then(WatchMaildirEnvelopes::new)
.map(WatchMaildirEnvelopes::new_boxed)
});
}
#[cfg(feature = "notmuch")]
Some(BackendKind::Notmuch) => {
// TODO
// builder.set_watch_envelopes(|ctx| {
// ctx.notmuch.as_ref().map(WatchNotmuchEnvelopes::new_boxed)
// });
}
_ => (),
},
)
Expand Down
19 changes: 13 additions & 6 deletions src/email/envelope/flag/command/add.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use clap::Parser;
#[cfg(feature = "imap")]
use email::flag::add::imap::AddFlagsImap;
use email::flag::add::imap::AddImapFlags;
#[cfg(feature = "maildir")]
use email::flag::add::maildir::AddFlagsMaildir;
use email::flag::add::maildir::AddMaildirFlags;
#[cfg(feature = "notmuch")]
use email::flag::add::notmuch::AddFlagsNotmuch;
use email::flag::add::notmuch::AddNotmuchFlags;
use log::info;

#[cfg(feature = "account-sync")]
Expand Down Expand Up @@ -60,19 +60,26 @@ impl FlagAddCommand {
|builder| match add_flags_kind {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder.set_add_flags(|ctx| ctx.imap.as_ref().and_then(AddFlagsImap::new));
builder.set_add_flags(|ctx| ctx.imap.as_ref().map(AddImapFlags::new_boxed));
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder
.set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new));
.set_add_flags(|ctx| ctx.maildir.as_ref().map(AddMaildirFlags::new_boxed));
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_add_flags(|ctx| {
ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new)
ctx.maildir_for_sync
.as_ref()
.map(AddMaildirFlags::new_boxed)
});
}
#[cfg(feature = "notmuch")]
Some(BackendKind::Notmuch) => {
builder
.set_add_flags(|ctx| ctx.notmuch.as_ref().map(AddNotmuchFlags::new_boxed));
}
_ => (),
},
)
Expand Down
18 changes: 12 additions & 6 deletions src/email/envelope/flag/command/remove.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use clap::Parser;
#[cfg(feature = "imap")]
use email::flag::remove::imap::RemoveFlagsImap;
use email::flag::remove::imap::RemoveImapFlags;
#[cfg(feature = "maildir")]
use email::flag::remove::maildir::RemoveFlagsMaildir;
use email::flag::remove::maildir::RemoveMaildirFlags;
#[cfg(feature = "notmuch")]
use email::flag::remove::notmuch::RemoveFlagsNotmuch;
use email::flag::remove::notmuch::RemoveNotmuchFlags;
use log::info;

#[cfg(feature = "account-sync")]
Expand Down Expand Up @@ -61,20 +61,26 @@ impl FlagRemoveCommand {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder
.set_remove_flags(|ctx| ctx.imap.as_ref().and_then(RemoveFlagsImap::new));
.set_remove_flags(|ctx| ctx.imap.as_ref().map(RemoveImapFlags::new_boxed));
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder.set_remove_flags(|ctx| {
ctx.maildir.as_ref().and_then(RemoveFlagsMaildir::new)
ctx.maildir.as_ref().map(RemoveMaildirFlags::new_boxed)
});
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_remove_flags(|ctx| {
ctx.maildir_for_sync
.as_ref()
.and_then(RemoveFlagsMaildir::new)
.map(RemoveMaildirFlags::new_boxed)
});
}
#[cfg(feature = "notmuch")]
Some(BackendKind::Notmuch) => {
builder.set_remove_flags(|ctx| {
ctx.notmuch.as_ref().map(RemoveNotmuchFlags::new_boxed)
});
}
_ => (),
Expand Down
19 changes: 13 additions & 6 deletions src/email/envelope/flag/command/set.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Result;
use clap::Parser;
#[cfg(feature = "imap")]
use email::flag::set::imap::SetFlagsImap;
use email::flag::set::imap::SetImapFlags;
#[cfg(feature = "maildir")]
use email::flag::set::maildir::SetFlagsMaildir;
use email::flag::set::maildir::SetMaildirFlags;
#[cfg(feature = "notmuch")]
use email::flag::set::notmuch::SetFlagsNotmuch;
use email::flag::set::notmuch::SetNotmuchFlags;
use log::info;

#[cfg(feature = "account-sync")]
Expand Down Expand Up @@ -60,19 +60,26 @@ impl FlagSetCommand {
|builder| match set_flags_kind {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder.set_set_flags(|ctx| ctx.imap.as_ref().and_then(SetFlagsImap::new));
builder.set_set_flags(|ctx| ctx.imap.as_ref().map(SetImapFlags::new_boxed));
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder
.set_set_flags(|ctx| ctx.maildir.as_ref().and_then(SetFlagsMaildir::new));
.set_set_flags(|ctx| ctx.maildir.as_ref().map(SetMaildirFlags::new_boxed));
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_set_flags(|ctx| {
ctx.maildir_for_sync.as_ref().and_then(SetFlagsMaildir::new)
ctx.maildir_for_sync
.as_ref()
.map(SetMaildirFlags::new_boxed)
});
}
#[cfg(feature = "notmuch")]
Some(BackendKind::Notmuch) => {
builder
.set_set_flags(|ctx| ctx.notmuch.as_ref().map(SetNotmuchFlags::new_boxed));
}
_ => (),
},
)
Expand Down
16 changes: 9 additions & 7 deletions src/email/message/attachment/command/download.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::{Context, Result};
use clap::Parser;
#[cfg(feature = "imap")]
use email::message::get::imap::GetMessagesImap;
use email::message::get::imap::GetImapMessages;
#[cfg(feature = "maildir")]
use email::{flag::add::maildir::AddFlagsMaildir, message::peek::maildir::PeekMessagesMaildir};
use email::{flag::add::maildir::AddMaildirFlags, message::peek::maildir::PeekMaildirMessages};
use log::info;
use std::{fs, path::PathBuf};
use uuid::Uuid;
Expand Down Expand Up @@ -62,25 +62,27 @@ impl AttachmentDownloadCommand {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder
.set_get_messages(|ctx| ctx.imap.as_ref().and_then(GetMessagesImap::new));
.set_get_messages(|ctx| ctx.imap.as_ref().map(GetImapMessages::new_boxed));
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder.set_peek_messages(|ctx| {
ctx.maildir.as_ref().and_then(PeekMessagesMaildir::new)
ctx.maildir.as_ref().map(PeekMaildirMessages::new_boxed)
});
builder
.set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new));
.set_add_flags(|ctx| ctx.maildir.as_ref().map(AddMaildirFlags::new_boxed));
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_peek_messages(|ctx| {
ctx.maildir_for_sync
.as_ref()
.and_then(PeekMessagesMaildir::new)
.map(PeekMaildirMessages::new_boxed)
});
builder.set_add_flags(|ctx| {
ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new)
ctx.maildir_for_sync
.as_ref()
.map(AddMaildirFlags::new_boxed)
});
}
_ => (),
Expand Down
13 changes: 7 additions & 6 deletions src/email/message/command/copy.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::Result;
use clap::Parser;
#[cfg(feature = "imap")]
use email::message::copy::imap::CopyMessagesImap;
use email::message::copy::imap::CopyImapMessages;
#[cfg(feature = "maildir")]
use email::message::copy::maildir::CopyMessagesMaildir;
use email::message::copy::maildir::CopyMaildirMessages;
use log::info;

#[cfg(feature = "account-sync")]
Expand Down Expand Up @@ -61,21 +61,22 @@ impl MessageCopyCommand {
|#[allow(unused)] builder| match copy_messages_kind {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder
.set_copy_messages(|ctx| ctx.imap.as_ref().and_then(CopyMessagesImap::new));
builder.set_copy_messages(|ctx| {
ctx.imap.as_ref().map(CopyImapMessages::new_boxed)
});
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder.set_copy_messages(|ctx| {
ctx.maildir.as_ref().and_then(CopyMessagesMaildir::new)
ctx.maildir.as_ref().map(CopyMaildirMessages::new_boxed)
});
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_copy_messages(|ctx| {
ctx.maildir_for_sync
.as_ref()
.and_then(CopyMessagesMaildir::new)
.map(CopyMaildirMessages::new_boxed)
});
}
_ => (),
Expand Down
21 changes: 12 additions & 9 deletions src/email/message/command/delete.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use anyhow::Result;
use clap::Parser;
#[cfg(feature = "imap")]
use email::{flag::add::imap::AddFlagsImap, message::move_::imap::MoveMessagesImap};
use email::{flag::add::imap::AddImapFlags, message::move_::imap::MoveImapMessages};
#[cfg(feature = "maildir")]
use email::{flag::add::maildir::AddFlagsMaildir, message::move_::maildir::MoveMessagesMaildir};
use email::{flag::add::maildir::AddMaildirFlags, message::move_::maildir::MoveMaildirMessages};
use log::info;

#[cfg(feature = "account-sync")]
Expand Down Expand Up @@ -62,27 +62,30 @@ impl MessageDeleteCommand {
|#[allow(unused)] builder| match delete_messages_kind {
#[cfg(feature = "imap")]
Some(BackendKind::Imap) => {
builder
.set_move_messages(|ctx| ctx.imap.as_ref().and_then(MoveMessagesImap::new));
builder.set_add_flags(|ctx| ctx.imap.as_ref().and_then(AddFlagsImap::new));
builder.set_move_messages(|ctx| {
ctx.imap.as_ref().map(MoveImapMessages::new_boxed)
});
builder.set_add_flags(|ctx| ctx.imap.as_ref().map(AddImapFlags::new_boxed));
}
#[cfg(feature = "maildir")]
Some(BackendKind::Maildir) => {
builder.set_move_messages(|ctx| {
ctx.maildir.as_ref().and_then(MoveMessagesMaildir::new)
ctx.maildir.as_ref().map(MoveMaildirMessages::new_boxed)
});
builder
.set_add_flags(|ctx| ctx.maildir.as_ref().and_then(AddFlagsMaildir::new));
.set_add_flags(|ctx| ctx.maildir.as_ref().map(AddMaildirFlags::new_boxed));
}
#[cfg(feature = "account-sync")]
Some(BackendKind::MaildirForSync) => {
builder.set_move_messages(|ctx| {
ctx.maildir_for_sync
.as_ref()
.and_then(MoveMessagesMaildir::new)
.map(MoveMaildirMessages::new_boxed)
});
builder.set_add_flags(|ctx| {
ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new)
ctx.maildir_for_sync
.as_ref()
.map(AddMaildirFlags::new_boxed)
});
}
_ => (),
Expand Down
Loading

0 comments on commit 3137e1e

Please sign in to comment.