From 8b1a289f4dfea3837fe2b6d62b2f04799eab4827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Mon, 4 Dec 2023 22:26:49 +0100 Subject: [PATCH] rename existing cargo features, fix imports --- Cargo.lock | 1 + Cargo.toml | 24 +++-- src/backend/config.rs | 20 ++-- src/backend/mod.rs | 156 +++++++++++++++---------------- src/backend/wizard.rs | 18 ++-- src/cache/id_mapper.rs | 2 +- src/config/config.rs | 29 +++--- src/config/prelude.rs | 39 ++++---- src/config/wizard.rs | 6 +- src/domain/account/accounts.rs | 6 +- src/domain/account/config.rs | 20 ++-- src/domain/account/handlers.rs | 26 +++--- src/domain/account/wizard.rs | 6 +- src/domain/email/handlers.rs | 5 +- src/domain/envelope/envelopes.rs | 12 +-- src/domain/flag/args.rs | 2 +- src/domain/flag/flag.rs | 6 +- src/domain/flag/flags.rs | 4 +- src/domain/flag/handlers.rs | 2 +- src/domain/folder/handlers.rs | 2 +- src/domain/tpl/handlers.rs | 5 +- src/imap/wizard.rs | 7 +- src/lib.rs | 6 +- src/maildir/wizard.rs | 2 +- src/main.rs | 4 +- src/printer/print_table.rs | 2 +- src/sendmail/wizard.rs | 2 +- src/smtp/wizard.rs | 7 +- src/ui/editor.rs | 5 +- src/ui/table/table.rs | 4 +- 30 files changed, 224 insertions(+), 206 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2dba8c7..2c12a90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2068,6 +2068,7 @@ dependencies = [ "indicatif", "keyring-lib", "log", + "mail-builder", "md5", "mml-lib", "oauth-lib 0.1.0", diff --git a/Cargo.toml b/Cargo.toml index 2f7eea1..9759e3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,20 +10,27 @@ keywords = ["cli", "mail", "email", "client", "imap"] homepage = "https://pimalaya.org/himalaya" documentation = "https://pimalaya.org/himalaya/" repository = "https://github.com/soywod/himalaya/" -metadata.docs.rs.all-features = true + +[package.metadata.docs.rs] +all-features = true +rustdoc-args = ["--cfg", "docsrs"] [features] default = [ - "imap-backend", - # "notmuch-backend", - "smtp-sender", + "maildir", + "imap", + # "notmuch", + "smtp", + "sendmail", # "pgp-commands", # "pgp-gpg", # "pgp-native", ] -imap-backend = ["email-lib/imap-backend"] -notmuch-backend = ["email-lib/notmuch-backend"] -smtp-sender = ["email-lib/smtp-sender"] +maildir = ["email-lib/maildir"] +imap = ["email-lib/imap"] +notmuch = ["email-lib/notmuch"] +smtp = ["email-lib/smtp"] +sendmail = ["email-lib/sendmail"] pgp = [] pgp-commands = ["pgp", "mml-lib/pgp-commands", "email-lib/pgp-commands"] pgp-gpg = ["pgp", "mml-lib/pgp-gpg", "email-lib/pgp-gpg"] @@ -98,6 +105,9 @@ path = "/home/soywod/sourcehut/pimalaya/email" [dependencies.keyring-lib] version = "=0.1.0" +[dependencies.mail-builder] +version = "0.3" + [dependencies.oauth-lib] # version = "=0.1.0" path = "/home/soywod/sourcehut/pimalaya/oauth" diff --git a/src/backend/config.rs b/src/backend/config.rs index fb18479..2284de3 100644 --- a/src/backend/config.rs +++ b/src/backend/config.rs @@ -1,19 +1,19 @@ -#[cfg(feature = "imap-backend")] -use email::imap::ImapConfig; -#[cfg(feature = "notmuch-backend")] -use email::notmuch::NotmuchConfig; -#[cfg(feature = "smtp-sender")] -use email::smtp::SmtpConfig; -use email::{maildir::MaildirConfig, sendmail::SendmailConfig}; +#[cfg(feature = "imap")] +use email::imap::config::ImapConfig; +#[cfg(feature = "notmuch")] +use email::notmuch::config::NotmuchConfig; +#[cfg(feature = "smtp")] +use email::smtp::config::SmtpConfig; +use email::{maildir::config::MaildirConfig, sendmail::config::SendmailConfig}; #[derive(Clone, Debug, Eq, PartialEq)] pub enum BackendConfig { Maildir(MaildirConfig), - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Imap(ImapConfig), - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Notmuch(NotmuchConfig), - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] Smtp(SmtpConfig), Sendmail(SendmailConfig), } diff --git a/src/backend/mod.rs b/src/backend/mod.rs index c92ddec..1c9af19 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -5,36 +5,23 @@ use anyhow::Result; use async_trait::async_trait; use std::ops::Deref; -#[cfg(feature = "imap-backend")] +#[cfg(feature = "imap")] use email::imap::{ImapSessionBuilder, ImapSessionSync}; -#[cfg(feature = "smtp-sender")] +#[cfg(feature = "smtp")] use email::smtp::{SmtpClientBuilder, SmtpClientSync}; use email::{ - account::AccountConfig, - email::{ - envelope::{ - get::{imap::GetEnvelopeImap, maildir::GetEnvelopeMaildir}, - list::{imap::ListEnvelopesImap, maildir::ListEnvelopesMaildir}, - }, - flag::{ - add::{imap::AddFlagsImap, maildir::AddFlagsMaildir}, - remove::{imap::RemoveFlagsImap, maildir::RemoveFlagsMaildir}, - set::{imap::SetFlagsImap, maildir::SetFlagsMaildir}, - }, - message::{ - add_raw::imap::AddRawMessageImap, - add_raw_with_flags::{ - imap::AddRawMessageWithFlagsImap, maildir::AddRawMessageWithFlagsMaildir, - }, - copy::{imap::CopyMessagesImap, maildir::CopyMessagesMaildir}, - get::imap::GetMessagesImap, - move_::{imap::MoveMessagesImap, maildir::MoveMessagesMaildir}, - peek::{imap::PeekMessagesImap, maildir::PeekMessagesMaildir}, - send_raw::{sendmail::SendRawMessageSendmail, smtp::SendRawMessageSmtp}, - }, + account::config::AccountConfig, + envelope::{ + get::{imap::GetEnvelopeImap, maildir::GetEnvelopeMaildir}, + list::{imap::ListEnvelopesImap, maildir::ListEnvelopesMaildir}, + Id, SingleId, + }, + flag::{ + add::{imap::AddFlagsImap, maildir::AddFlagsMaildir}, + remove::{imap::RemoveFlagsImap, maildir::RemoveFlagsMaildir}, + set::{imap::SetFlagsImap, maildir::SetFlagsMaildir}, + Flags, }, - envelope::{Id, SingleId}, - flag::Flags, folder::{ add::{imap::AddFolderImap, maildir::AddFolderMaildir}, delete::{imap::DeleteFolderImap, maildir::DeleteFolderMaildir}, @@ -42,8 +29,19 @@ use email::{ list::{imap::ListFoldersImap, maildir::ListFoldersMaildir}, purge::imap::PurgeFolderImap, }, - maildir::{MaildirConfig, MaildirSessionBuilder, MaildirSessionSync}, - message::Messages, + maildir::{config::MaildirConfig, MaildirSessionBuilder, MaildirSessionSync}, + message::{ + add_raw::imap::AddRawMessageImap, + add_raw_with_flags::{ + imap::AddRawMessageWithFlagsImap, maildir::AddRawMessageWithFlagsMaildir, + }, + copy::{imap::CopyMessagesImap, maildir::CopyMessagesMaildir}, + get::imap::GetMessagesImap, + move_::{imap::MoveMessagesImap, maildir::MoveMessagesMaildir}, + peek::{imap::PeekMessagesImap, maildir::PeekMessagesMaildir}, + send_raw::{sendmail::SendRawMessageSendmail, smtp::SendRawMessageSmtp}, + Messages, + }, sendmail::SendmailContext, }; use serde::{Deserialize, Serialize}; @@ -56,11 +54,11 @@ pub enum BackendKind { Maildir, #[serde(skip_deserializing)] MaildirForSync, - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Imap, - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Notmuch, - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] Smtp, Sendmail, } @@ -70,11 +68,11 @@ impl ToString for BackendKind { let kind = match self { Self::Maildir => "Maildir", Self::MaildirForSync => "Maildir", - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Self::Imap => "IMAP", - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Self::Notmuch => "Notmuch", - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] Self::Smtp => "SMTP", Self::Sendmail => "Sendmail", }; @@ -87,9 +85,9 @@ impl ToString for BackendKind { pub struct BackendContextBuilder { maildir: Option, maildir_for_sync: Option, - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] imap: Option, - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] smtp: Option, sendmail: Option, } @@ -109,17 +107,17 @@ impl email::backend::BackendContextBuilder for BackendContextBuilder { ctx.maildir_for_sync = Some(maildir.build().await?); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] if let Some(imap) = self.imap { ctx.imap = Some(imap.build().await?); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] if let Some(notmuch) = self.notmuch { ctx.notmuch = Some(notmuch.build().await?); } - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] if let Some(smtp) = self.smtp { ctx.smtp = Some(smtp.build().await?); } @@ -136,9 +134,9 @@ impl email::backend::BackendContextBuilder for BackendContextBuilder { pub struct BackendContext { pub maildir: Option, pub maildir_for_sync: Option, - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] pub imap: Option, - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] pub smtp: Option, pub sendmail: Option, } @@ -158,11 +156,11 @@ impl BackendBuilder { let is_maildir_used = used_backends.contains(&BackendKind::Maildir); let is_maildir_for_sync_used = used_backends.contains(&BackendKind::MaildirForSync); - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] let is_imap_used = used_backends.contains(&BackendKind::Imap); - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] let is_notmuch_used = used_backends.contains(&BackendKind::Notmuch); - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] let is_smtp_used = used_backends.contains(&BackendKind::Smtp); let is_sendmail_used = used_backends.contains(&BackendKind::Sendmail); @@ -180,7 +178,7 @@ impl BackendBuilder { .filter(|_| is_maildir_for_sync_used) .map(|mdir_config| MaildirSessionBuilder::new(account_config.clone(), mdir_config)), - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] imap: { let ctx_builder = toml_account_config .imap @@ -196,7 +194,7 @@ impl BackendBuilder { None => None, } }, - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] notmuch: toml_account_config .notmuch .as_ref() @@ -204,7 +202,7 @@ impl BackendBuilder { .map(|notmuch_config| { NotmuchSessionBuilder::new(account_config.clone(), notmuch_config.clone()) }), - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] smtp: toml_account_config .smtp .as_ref() @@ -238,12 +236,12 @@ impl BackendBuilder { .and_then(AddFolderMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_add_folder(|ctx| ctx.imap.as_ref().and_then(AddFolderImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder .with_add_folder(|ctx| ctx.notmuch.as_ref().and_then(AddFolderNotmuch::new)); @@ -264,12 +262,12 @@ impl BackendBuilder { .and_then(ListFoldersMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_list_folders(|ctx| ctx.imap.as_ref().and_then(ListFoldersImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_list_folders(|ctx| { ctx.notmuch.as_ref().and_then(ListFoldersNotmuch::new) @@ -291,12 +289,12 @@ impl BackendBuilder { .and_then(ExpungeFolderMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_expunge_folder(|ctx| ctx.imap.as_ref().and_then(ExpungeFolderImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_expunge_folder(|ctx| { ctx.notmuch.as_ref().and_then(ExpungeFolderNotmuch::new) @@ -316,12 +314,12 @@ impl BackendBuilder { // backend_builder = backend_builder // .with_purge_folder(|ctx| ctx.maildir_for_sync.as_ref().and_then(PurgeFolderMaildir::new)); // } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_purge_folder(|ctx| ctx.imap.as_ref().and_then(PurgeFolderImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_purge_folder(|ctx| { ctx.notmuch.as_ref().and_then(PurgeFolderNotmuch::new) @@ -343,12 +341,12 @@ impl BackendBuilder { .and_then(DeleteFolderMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_delete_folder(|ctx| ctx.imap.as_ref().and_then(DeleteFolderImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_delete_folder(|ctx| { ctx.notmuch.as_ref().and_then(DeleteFolderNotmuch::new) @@ -370,12 +368,12 @@ impl BackendBuilder { .and_then(GetEnvelopeMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_get_envelope(|ctx| ctx.imap.as_ref().and_then(GetEnvelopeImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_get_envelope(|ctx| { ctx.notmuch.as_ref().and_then(GetEnvelopeNotmuch::new) @@ -397,12 +395,12 @@ impl BackendBuilder { .and_then(ListEnvelopesMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_list_envelopes(|ctx| ctx.imap.as_ref().and_then(ListEnvelopesImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_list_envelopes(|ctx| { ctx.notmuch.as_ref().and_then(ListEnvelopesNotmuch::new) @@ -421,12 +419,12 @@ impl BackendBuilder { ctx.maildir_for_sync.as_ref().and_then(AddFlagsMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_add_flags(|ctx| ctx.imap.as_ref().and_then(AddFlagsImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder .with_add_flags(|ctx| ctx.notmuch.as_ref().and_then(AddFlagsNotmuch::new)); @@ -444,12 +442,12 @@ impl BackendBuilder { ctx.maildir_for_sync.as_ref().and_then(SetFlagsMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_set_flags(|ctx| ctx.imap.as_ref().and_then(SetFlagsImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder .with_set_flags(|ctx| ctx.notmuch.as_ref().and_then(SetFlagsNotmuch::new)); @@ -470,12 +468,12 @@ impl BackendBuilder { .and_then(RemoveFlagsMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_remove_flags(|ctx| ctx.imap.as_ref().and_then(RemoveFlagsImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_remove_flags(|ctx| { ctx.notmuch.as_ref().and_then(RemoveFlagsNotmuch::new) @@ -485,7 +483,7 @@ impl BackendBuilder { } match toml_account_config.send_raw_message_kind() { - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] Some(BackendKind::Smtp) => { backend_builder = backend_builder.with_send_raw_message(|ctx| { ctx.smtp.as_ref().and_then(SendRawMessageSmtp::new) @@ -514,7 +512,7 @@ impl BackendBuilder { .and_then(AddRawMessageWithFlagsMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_add_raw_message(|ctx| ctx.imap.as_ref().and_then(AddRawMessageImap::new)) @@ -522,7 +520,7 @@ impl BackendBuilder { ctx.imap.as_ref().and_then(AddRawMessageWithFlagsImap::new) }); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_add_raw_message(|ctx| { ctx.notmuch.as_ref().and_then(AddRawMessageNotmuch::new) @@ -544,12 +542,12 @@ impl BackendBuilder { .and_then(PeekMessagesMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_peek_messages(|ctx| ctx.imap.as_ref().and_then(PeekMessagesImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_peek_messages(|ctx| { ctx.notmuch.as_ref().and_then(PeekMessagesNotmuch::new) @@ -559,12 +557,12 @@ impl BackendBuilder { } match toml_account_config.get_messages_kind() { - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_get_messages(|ctx| ctx.imap.as_ref().and_then(GetMessagesImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_get_messages(|ctx| { ctx.notmuch.as_ref().and_then(GetMessagesNotmuch::new) @@ -586,12 +584,12 @@ impl BackendBuilder { .and_then(CopyMessagesMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_copy_messages(|ctx| ctx.imap.as_ref().and_then(CopyMessagesImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_copy_messages(|ctx| { ctx.notmuch.as_ref().and_then(CopyMessagesNotmuch::new) @@ -613,12 +611,12 @@ impl BackendBuilder { .and_then(MoveMessagesMaildir::new) }); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendKind::Imap) => { backend_builder = backend_builder .with_move_messages(|ctx| ctx.imap.as_ref().and_then(MoveMessagesImap::new)); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { backend_builder = backend_builder.with_move_messages(|ctx| { ctx.notmuch.as_ref().and_then(MoveMessagesNotmuch::new) @@ -696,7 +694,7 @@ impl Backend { self.backend.account_config.sync_dir()?, )?; } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendKind::Notmuch) => { if let Some(notmuch_config) = &self.toml_account_config.notmuch { id_mapper = IdMapper::new( diff --git a/src/backend/wizard.rs b/src/backend/wizard.rs index 4234889..475dcbf 100644 --- a/src/backend/wizard.rs +++ b/src/backend/wizard.rs @@ -1,26 +1,26 @@ use anyhow::Result; use dialoguer::Select; -#[cfg(feature = "imap-backend")] +#[cfg(feature = "imap")] use crate::imap; -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] use crate::notmuch; -#[cfg(feature = "smtp-sender")] +#[cfg(feature = "smtp")] use crate::smtp; use crate::{config::wizard::THEME, maildir, sendmail}; use super::{config::BackendConfig, BackendKind}; const DEFAULT_BACKEND_KINDS: &[BackendKind] = &[ - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] BackendKind::Imap, BackendKind::Maildir, - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] BackendKind::Notmuch, ]; const SEND_MESSAGE_BACKEND_KINDS: &[BackendKind] = &[ - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] BackendKind::Smtp, BackendKind::Sendmail, ]; @@ -35,11 +35,11 @@ pub(crate) async fn configure(account_name: &str, email: &str) -> Result Some(maildir::wizard::configure()?), - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(kind) if kind == BackendKind::Imap => { Some(imap::wizard::configure(account_name, email).await?) } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(kind) if kind == BackendKind::Notmuch => Some(notmuch::wizard::configure()?), _ => None, }; @@ -60,7 +60,7 @@ pub(crate) async fn configure_sender( let config = match kind { Some(kind) if kind == BackendKind::Sendmail => Some(sendmail::wizard::configure()?), - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] Some(kind) if kind == BackendKind::Smtp => { Some(smtp::wizard::configure(account_name, email).await?) } diff --git a/src/cache/id_mapper.rs b/src/cache/id_mapper.rs index fb2ff86..7668aa9 100644 --- a/src/cache/id_mapper.rs +++ b/src/cache/id_mapper.rs @@ -1,5 +1,5 @@ use anyhow::{anyhow, Context, Result}; -use email::account::AccountConfig; +use email::account::config::AccountConfig; use log::{debug, trace}; use std::path::{Path, PathBuf}; diff --git a/src/config/config.rs b/src/config/config.rs index cdc4670..6a166dd 100644 --- a/src/config/config.rs +++ b/src/config/config.rs @@ -7,9 +7,9 @@ use anyhow::{anyhow, Context, Result}; use dialoguer::Confirm; use dirs::{config_dir, home_dir}; use email::{ - account::AccountConfig, + account::config::AccountConfig, config::Config, - email::{EmailHooks, EmailTextPlainFormat}, + email::config::{EmailHooks, EmailTextPlainFormat}, }; use serde::{Deserialize, Serialize}; use std::{ @@ -184,14 +184,14 @@ impl TomlConfig { .ok_or_else(|| anyhow!("cannot find account {name}")), }?; - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] if let Some(imap_config) = toml_account_config.imap.as_mut() { imap_config .auth .replace_undefined_keyring_entries(&account_name); } - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] if let Some(smtp_config) = toml_account_config.smtp.as_mut() { smtp_config .auth @@ -268,18 +268,17 @@ impl TomlConfig { #[cfg(test)] mod tests { use email::{ - account::PasswdConfig, - backend::{BackendConfig, MaildirConfig}, - sender::{SenderConfig, SendmailConfig}, + account::config::passwd::PasswdConfig, maildir::config::MaildirConfig, + sendmail::config::SendmailConfig, }; use secret::Secret; - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] use email::backend::NotmuchConfig; - #[cfg(feature = "imap-backend")] - use email::backend::{ImapAuthConfig, ImapConfig}; - #[cfg(feature = "smtp-sender")] - use email::sender::{SmtpAuthConfig, SmtpConfig}; + #[cfg(feature = "imap")] + use email::imap::config::{ImapAuthConfig, ImapConfig}; + #[cfg(feature = "smtp")] + use email::smtp::config::{SmtpAuthConfig, SmtpConfig}; use std::io::Write; use tempfile::NamedTempFile; @@ -435,7 +434,7 @@ mod tests { .contains("missing field `maildir-root-dir`")); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] #[tokio::test] async fn account_backend_notmuch_missing_db_path_field() { let config = make_config( @@ -588,7 +587,7 @@ mod tests { ) } - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] #[tokio::test] async fn account_smtp_sender_minimum_config() { use email::sender::SenderConfig; @@ -727,7 +726,7 @@ mod tests { ) } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] #[tokio::test] async fn account_backend_notmuch_minimum_config() { let config = make_config( diff --git a/src/config/prelude.rs b/src/config/prelude.rs index df1aaa7..4728a0f 100644 --- a/src/config/prelude.rs +++ b/src/config/prelude.rs @@ -6,18 +6,21 @@ use email::account::GpgConfig; use email::account::PgpConfig; #[cfg(feature = "pgp-native")] use email::account::{NativePgpConfig, NativePgpSecretKey, SignedSecretKey}; -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] use email::backend::NotmuchConfig; -#[cfg(feature = "imap-backend")] -use email::imap::{ImapAuthConfig, ImapConfig}; -#[cfg(feature = "smtp-sender")] -use email::smtp::{SmtpAuthConfig, SmtpConfig}; +#[cfg(feature = "imap")] +use email::imap::config::{ImapAuthConfig, ImapConfig}; +#[cfg(feature = "smtp")] +use email::smtp::config::{SmtpAuthConfig, SmtpConfig}; use email::{ - account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig}, - email::{EmailHooks, EmailTextPlainFormat}, + account::config::{ + oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes}, + passwd::PasswdConfig, + }, + email::config::{EmailHooks, EmailTextPlainFormat}, folder::sync::FolderSyncStrategy, - maildir::MaildirConfig, - sendmail::SendmailConfig, + maildir::config::MaildirConfig, + sendmail::config::SendmailConfig, }; use keyring::Entry; use process::{Cmd, Pipeline, SingleCmd}; @@ -159,7 +162,7 @@ impl Into for Option { } } -#[cfg(feature = "imap-backend")] +#[cfg(feature = "imap")] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(remote = "ImapConfig", rename_all = "kebab-case")] pub struct ImapConfigDef { @@ -176,7 +179,7 @@ pub struct ImapConfigDef { pub watch_cmds: Option>, } -#[cfg(feature = "imap-backend")] +#[cfg(feature = "imap")] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(remote = "ImapAuthConfig", tag = "auth")] pub enum ImapAuthConfigDef { @@ -303,7 +306,7 @@ pub struct MaildirConfigDef { pub root_dir: PathBuf, } -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] #[serde( remote = "Option", @@ -312,7 +315,7 @@ pub struct MaildirConfigDef { )] pub struct OptionNotmuchConfigDef; -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] pub struct OptionNotmuchConfig { #[serde(default, skip)] @@ -321,7 +324,7 @@ pub struct OptionNotmuchConfig { inner: NotmuchConfig, } -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] impl From for Option { fn from(config: OptionNotmuchConfig) -> Option { if config.is_none { @@ -332,7 +335,7 @@ impl From for Option { } } -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] impl Into for Option { fn into(self) -> OptionNotmuchConfig { match self { @@ -348,7 +351,7 @@ impl Into for Option { } } -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] #[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] #[serde(remote = "NotmuchConfig", rename_all = "kebab-case")] pub struct NotmuchConfigDef { @@ -452,7 +455,7 @@ impl Into for Option { } } -#[cfg(feature = "smtp-sender")] +#[cfg(feature = "smtp")] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(remote = "SmtpConfig")] struct SmtpConfigDef { @@ -466,7 +469,7 @@ struct SmtpConfigDef { pub auth: SmtpAuthConfig, } -#[cfg(feature = "smtp-sender")] +#[cfg(feature = "smtp")] #[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] #[serde(remote = "SmtpAuthConfig", tag = "auth")] pub enum SmtpAuthConfigDef { diff --git a/src/config/wizard.rs b/src/config/wizard.rs index ffb3a23..8d43942 100644 --- a/src/config/wizard.rs +++ b/src/config/wizard.rs @@ -128,17 +128,17 @@ pub(crate) async fn configure(path: PathBuf) -> Result { }); set_table_dotted(item, "maildir"); - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] { set_table_dotted(item, "imap"); get_table_mut(item, "imap").map(|item| { set_tables_dotted(item, ["passwd", "oauth2"]); }); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] set_table_dotted(item, "notmuch"); set_table_dotted(item, "sendmail"); - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] { set_table_dotted(item, "smtp"); get_table_mut(item, "smtp").map(|item| { diff --git a/src/domain/account/accounts.rs b/src/domain/account/accounts.rs index 59a4579..c567044 100644 --- a/src/domain/account/accounts.rs +++ b/src/domain/account/accounts.rs @@ -42,7 +42,7 @@ impl From> for Accounts { .map(|(name, account)| { let mut backends = String::new(); - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] if account.imap.is_some() { backends.push_str("imap"); } @@ -54,7 +54,7 @@ impl From> for Accounts { backends.push_str("maildir"); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] if account.imap.is_some() { if !backends.is_empty() { backends.push_str(", ") @@ -62,7 +62,7 @@ impl From> for Accounts { backends.push_str("notmuch"); } - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] if account.smtp.is_some() { if !backends.is_empty() { backends.push_str(", ") diff --git a/src/domain/account/config.rs b/src/domain/account/config.rs index 01186ae..5f289fe 100644 --- a/src/domain/account/config.rs +++ b/src/domain/account/config.rs @@ -5,15 +5,15 @@ #[cfg(feature = "pgp")] use email::account::PgpConfig; -#[cfg(feature = "imap-backend")] -use email::imap::ImapConfig; -#[cfg(feature = "smtp-sender")] -use email::smtp::SmtpConfig; +#[cfg(feature = "imap")] +use email::imap::config::ImapConfig; +#[cfg(feature = "smtp")] +use email::smtp::config::SmtpConfig; use email::{ - email::{EmailHooks, EmailTextPlainFormat}, + email::config::{EmailHooks, EmailTextPlainFormat}, folder::sync::FolderSyncStrategy, - maildir::MaildirConfig, - sendmail::SendmailConfig, + maildir::config::MaildirConfig, + sendmail::config::SendmailConfig, }; use serde::{Deserialize, Serialize}; use std::{ @@ -79,7 +79,7 @@ pub struct TomlAccountConfig { pub flag: Option, pub message: Option, - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] #[serde( default, with = "OptionImapConfigDef", @@ -94,7 +94,7 @@ pub struct TomlAccountConfig { )] pub maildir: Option, - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] #[serde( default, with = "OptionNotmuchConfigDef", @@ -102,7 +102,7 @@ pub struct TomlAccountConfig { )] pub notmuch: Option, - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] #[serde( default, with = "OptionSmtpConfigDef", diff --git a/src/domain/account/handlers.rs b/src/domain/account/handlers.rs index 0905563..a37c9dd 100644 --- a/src/domain/account/handlers.rs +++ b/src/domain/account/handlers.rs @@ -4,13 +4,13 @@ use anyhow::Result; use email::account::{ + config::AccountConfig, sync::{AccountSyncBuilder, AccountSyncProgressEvent}, - AccountConfig, }; -#[cfg(feature = "imap-backend")] -use email::imap::ImapAuthConfig; -#[cfg(feature = "smtp-sender")] -use email::smtp::SmtpAuthConfig; +#[cfg(feature = "imap")] +use email::imap::config::ImapAuthConfig; +#[cfg(feature = "smtp")] +use email::smtp::config::SmtpAuthConfig; use indicatif::{MultiProgress, ProgressBar, ProgressFinish, ProgressStyle}; use log::{debug, info, trace, warn}; use once_cell::sync::Lazy; @@ -48,7 +48,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> { info!("entering the configure account handler"); if reset { - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] if let Some(ref config) = config.imap { let reset = match &config.auth { ImapAuthConfig::Passwd(config) => config.reset(), @@ -60,7 +60,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> { } } - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] if let Some(ref config) = config.smtp { let reset = match &config.auth { SmtpAuthConfig::Passwd(config) => config.reset(), @@ -78,7 +78,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> { } } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] if let Some(ref config) = config.imap { match &config.auth { ImapAuthConfig::Passwd(config) => { @@ -92,7 +92,7 @@ pub async fn configure(config: &TomlAccountConfig, reset: bool) -> Result<()> { }?; } - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] if let Some(ref config) = config.smtp { match &config.auth { SmtpAuthConfig::Passwd(config) => { @@ -299,12 +299,13 @@ pub async fn sync( #[cfg(test)] mod tests { - use email::{account::AccountConfig, backend::ImapConfig}; + use email::{account::config::AccountConfig, imap::config::ImapConfig}; use std::{collections::HashMap, fmt::Debug, io}; use termcolor::ColorSpec; use crate::{ account::TomlAccountConfig, + backend::BackendKind, printer::{Print, PrintTable, WriteColor}, }; @@ -378,8 +379,9 @@ mod tests { "account-1".into(), TomlAccountConfig { default: Some(true), - backend: BackendConfig::Imap(ImapConfig::default()), - ..TomlAccountConfig::default() + backend: Some(BackendKind::Imap), + imap: Some(ImapConfig::default()), + ..Default::default() }, )]), ..TomlConfig::default() diff --git a/src/domain/account/wizard.rs b/src/domain/account/wizard.rs index 5096585..c470011 100644 --- a/src/domain/account/wizard.rs +++ b/src/domain/account/wizard.rs @@ -40,12 +40,12 @@ pub(crate) async fn configure() -> Result> { config.maildir = Some(mdir_config); config.backend = Some(BackendKind::Maildir); } - #[cfg(feature = "imap-backend")] + #[cfg(feature = "imap")] Some(BackendConfig::Imap(imap_config)) => { config.imap = Some(imap_config); config.backend = Some(BackendKind::Imap); } - #[cfg(feature = "notmuch-backend")] + #[cfg(feature = "notmuch")] Some(BackendConfig::Notmuch(notmuch_config)) => { config.notmuch = Some(notmuch_config); config.backend = Some(BackendKind::Notmuch); @@ -64,7 +64,7 @@ pub(crate) async fn configure() -> Result> { ..Default::default() }); } - #[cfg(feature = "smtp-sender")] + #[cfg(feature = "smtp")] Some(BackendConfig::Smtp(smtp_config)) => { config.smtp = Some(smtp_config); config.message = Some(MessageConfig { diff --git a/src/domain/email/handlers.rs b/src/domain/email/handlers.rs index fb15a2b..b835ce8 100644 --- a/src/domain/email/handlers.rs +++ b/src/domain/email/handlers.rs @@ -1,10 +1,11 @@ use anyhow::{anyhow, Context, Result}; use atty::Stream; use email::{ - account::AccountConfig, - email::{envelope::Id, template::FilterParts, Flag, Message, MessageBuilder}, + account::config::AccountConfig, envelope::Id, flag::Flag, message::Message, + template::FilterParts, }; use log::{debug, trace}; +use mail_builder::MessageBuilder; use std::{ fs, io::{self, BufRead}, diff --git a/src/domain/envelope/envelopes.rs b/src/domain/envelope/envelopes.rs index 9da59c8..ee1fdd3 100644 --- a/src/domain/envelope/envelopes.rs +++ b/src/domain/envelope/envelopes.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use email::account::AccountConfig; +use email::account::config::AccountConfig; use serde::Serialize; use std::ops; @@ -17,7 +17,7 @@ impl Envelopes { pub fn from_backend( config: &AccountConfig, id_mapper: &IdMapper, - envelopes: email::email::Envelopes, + envelopes: email::envelope::Envelopes, ) -> Result { let envelopes = envelopes .iter() @@ -59,7 +59,7 @@ impl PrintTable for Envelopes { #[cfg(test)] mod tests { use chrono::DateTime; - use email::account::AccountConfig; + use email::account::config::AccountConfig; use std::env; use crate::{Envelopes, IdMapper}; @@ -69,7 +69,7 @@ mod tests { let config = AccountConfig::default(); let id_mapper = IdMapper::Dummy; - let envelopes = email::email::Envelopes::from_iter([email::email::Envelope { + let envelopes = email::envelope::Envelopes::from_iter([email::envelope::Envelope { date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(), ..Default::default() }]); @@ -89,7 +89,7 @@ mod tests { ..AccountConfig::default() }; - let envelopes = email::email::Envelopes::from_iter([email::email::Envelope { + let envelopes = email::envelope::Envelopes::from_iter([email::envelope::Envelope { date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(), ..Default::default() }]); @@ -112,7 +112,7 @@ mod tests { ..AccountConfig::default() }; - let envelopes = email::email::Envelopes::from_iter([email::email::Envelope { + let envelopes = email::envelope::Envelopes::from_iter([email::envelope::Envelope { date: DateTime::parse_from_rfc3339("2023-06-15T09:42:00+04:00").unwrap(), ..Default::default() }]); diff --git a/src/domain/flag/args.rs b/src/domain/flag/args.rs index b365f13..bf3d438 100644 --- a/src/domain/flag/args.rs +++ b/src/domain/flag/args.rs @@ -3,7 +3,7 @@ //! This module contains the command matcher, the subcommands and the //! arguments related to the email flag domain. -use ::email::email::{Flag, Flags}; +use ::email::flag::{Flag, Flags}; use anyhow::Result; use clap::{Arg, ArgMatches, Command}; use log::{debug, info}; diff --git a/src/domain/flag/flag.rs b/src/domain/flag/flag.rs index e48f0bb..bf3712a 100644 --- a/src/domain/flag/flag.rs +++ b/src/domain/flag/flag.rs @@ -11,9 +11,9 @@ pub enum Flag { Custom(String), } -impl From<&email::email::Flag> for Flag { - fn from(flag: &email::email::Flag) -> Self { - use email::email::Flag::*; +impl From<&email::flag::Flag> for Flag { + fn from(flag: &email::flag::Flag) -> Self { + use email::flag::Flag::*; match flag { Seen => Flag::Seen, Answered => Flag::Answered, diff --git a/src/domain/flag/flags.rs b/src/domain/flag/flags.rs index bcf9f1f..d0c30d2 100644 --- a/src/domain/flag/flags.rs +++ b/src/domain/flag/flags.rs @@ -14,8 +14,8 @@ impl ops::Deref for Flags { } } -impl From for Flags { - fn from(flags: email::email::Flags) -> Self { +impl From for Flags { + fn from(flags: email::flag::Flags) -> Self { Flags(flags.iter().map(Flag::from).collect()) } } diff --git a/src/domain/flag/handlers.rs b/src/domain/flag/handlers.rs index 5316316..dc3812c 100644 --- a/src/domain/flag/handlers.rs +++ b/src/domain/flag/handlers.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use email::email::Flags; +use email::flag::Flags; use crate::{backend::Backend, printer::Printer}; diff --git a/src/domain/folder/handlers.rs b/src/domain/folder/handlers.rs index 9c6937e..44be274 100644 --- a/src/domain/folder/handlers.rs +++ b/src/domain/folder/handlers.rs @@ -4,7 +4,7 @@ use anyhow::Result; use dialoguer::Confirm; -use email::account::AccountConfig; +use email::account::config::AccountConfig; use std::process; use crate::{ diff --git a/src/domain/tpl/handlers.rs b/src/domain/tpl/handlers.rs index b036370..188bb74 100644 --- a/src/domain/tpl/handlers.rs +++ b/src/domain/tpl/handlers.rs @@ -1,9 +1,6 @@ use anyhow::{anyhow, Result}; use atty::Stream; -use email::{ - account::AccountConfig, - email::{Flag, Message}, -}; +use email::{account::config::AccountConfig, flag::Flag, message::Message}; use mml::MmlCompilerBuilder; use std::io::{stdin, BufRead}; diff --git a/src/imap/wizard.rs b/src/imap/wizard.rs index 00d6017..5efccfa 100644 --- a/src/imap/wizard.rs +++ b/src/imap/wizard.rs @@ -1,8 +1,11 @@ use anyhow::Result; use dialoguer::{Confirm, Input, Password, Select}; use email::{ - account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig}, - imap::{ImapAuthConfig, ImapConfig}, + account::config::{ + oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes}, + passwd::PasswdConfig, + }, + imap::config::{ImapAuthConfig, ImapConfig}, }; use oauth::v2_0::{AuthorizationCodeGrant, Client}; use secret::Secret; diff --git a/src/lib.rs b/src/lib.rs index f37795c..52e83b6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,16 +3,16 @@ pub mod cache; pub mod compl; pub mod config; pub mod domain; -#[cfg(feature = "imap-backend")] +#[cfg(feature = "imap")] pub mod imap; pub mod maildir; pub mod man; -#[cfg(feature = "notmuch-backend")] +#[cfg(feature = "notmuch")] pub mod notmuch; pub mod output; pub mod printer; pub mod sendmail; -#[cfg(feature = "smtp-sender")] +#[cfg(feature = "smtp")] pub mod smtp; pub mod ui; diff --git a/src/maildir/wizard.rs b/src/maildir/wizard.rs index 04a1e03..ee7b260 100644 --- a/src/maildir/wizard.rs +++ b/src/maildir/wizard.rs @@ -1,7 +1,7 @@ use anyhow::Result; use dialoguer::Input; use dirs::home_dir; -use email::maildir::MaildirConfig; +use email::maildir::config::MaildirConfig; use crate::{backend::config::BackendConfig, config::wizard::THEME}; diff --git a/src/main.rs b/src/main.rs index 46a9128..ad2e1df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use ::email::account::{sync::AccountSyncBuilder, DEFAULT_INBOX_FOLDER}; +use ::email::account::{config::DEFAULT_INBOX_FOLDER, sync::AccountSyncBuilder}; use anyhow::{anyhow, Context, Result}; use clap::Command; use log::{debug, warn}; @@ -91,7 +91,7 @@ async fn main() -> Result<()> { let mut printer = StdoutPrinter::try_from(&m)?; // FIXME - // #[cfg(feature = "imap-backend")] + // #[cfg(feature = "imap")] // if let BackendConfig::Imap(imap_config) = &account_config.backend { // let folder = folder.unwrap_or(DEFAULT_INBOX_FOLDER); // match imap::args::matches(&m)? { diff --git a/src/printer/print_table.rs b/src/printer/print_table.rs index 7066221..e371d9b 100644 --- a/src/printer/print_table.rs +++ b/src/printer/print_table.rs @@ -1,5 +1,5 @@ use anyhow::Result; -use email::email::EmailTextPlainFormat; +use email::email::config::EmailTextPlainFormat; use std::io; use termcolor::{self, StandardStream}; diff --git a/src/sendmail/wizard.rs b/src/sendmail/wizard.rs index e2a2896..1906b71 100644 --- a/src/sendmail/wizard.rs +++ b/src/sendmail/wizard.rs @@ -1,6 +1,6 @@ use anyhow::Result; use dialoguer::Input; -use email::sendmail::SendmailConfig; +use email::sendmail::config::SendmailConfig; use crate::{backend::config::BackendConfig, config::wizard::THEME}; diff --git a/src/smtp/wizard.rs b/src/smtp/wizard.rs index 6dab9cf..83d1aa1 100644 --- a/src/smtp/wizard.rs +++ b/src/smtp/wizard.rs @@ -1,8 +1,11 @@ use anyhow::Result; use dialoguer::{Confirm, Input, Select}; use email::{ - account::{OAuth2Config, OAuth2Method, OAuth2Scopes, PasswdConfig}, - smtp::{SmtpAuthConfig, SmtpConfig}, + account::config::{ + oauth2::{OAuth2Config, OAuth2Method, OAuth2Scopes}, + passwd::PasswdConfig, + }, + smtp::config::{SmtpAuthConfig, SmtpConfig}, }; use oauth::v2_0::{AuthorizationCodeGrant, Client}; use secret::Secret; diff --git a/src/ui/editor.rs b/src/ui/editor.rs index b65f461..34eef3c 100644 --- a/src/ui/editor.rs +++ b/src/ui/editor.rs @@ -1,7 +1,8 @@ use anyhow::{Context, Result}; use email::{ - account::AccountConfig, - email::{local_draft_path, remove_local_draft, Flag, Flags}, + account::config::AccountConfig, + email::utils::{local_draft_path, remove_local_draft}, + flag::{Flag, Flags}, }; use log::debug; use mml::MmlCompilerBuilder; diff --git a/src/ui/table/table.rs b/src/ui/table/table.rs index adbe2ca..685eb0a 100644 --- a/src/ui/table/table.rs +++ b/src/ui/table/table.rs @@ -5,7 +5,7 @@ //! [builder design pattern]: https://refactoring.guru/design-patterns/builder use anyhow::{Context, Result}; -use email::email::EmailTextPlainFormat; +use email::email::config::EmailTextPlainFormat; use log::trace; use termcolor::{Color, ColorSpec}; use terminal_size::terminal_size; @@ -267,7 +267,7 @@ where #[cfg(test)] mod tests { - use email::email::EmailTextPlainFormat; + use email::email::config::EmailTextPlainFormat; use std::io; use super::*;