rename existing cargo features, fix imports

This commit is contained in:
Clément DOUIN
2023-12-04 22:26:49 +01:00
parent ea9c28b9d7
commit 8b1a289f4d
30 changed files with 224 additions and 206 deletions
+14 -15
View File
@@ -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(
+21 -18
View File
@@ -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<OptionImapConfig> for Option<ImapConfig> {
}
}
#[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<Vec<String>>,
}
#[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<NotmuchConfig>",
@@ -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<OptionNotmuchConfig> for Option<NotmuchConfig> {
fn from(config: OptionNotmuchConfig) -> Option<NotmuchConfig> {
if config.is_none {
@@ -332,7 +335,7 @@ impl From<OptionNotmuchConfig> for Option<NotmuchConfig> {
}
}
#[cfg(feature = "notmuch-backend")]
#[cfg(feature = "notmuch")]
impl Into<OptionNotmuchConfig> for Option<NotmuchConfig> {
fn into(self) -> OptionNotmuchConfig {
match self {
@@ -348,7 +351,7 @@ impl Into<OptionNotmuchConfig> for Option<NotmuchConfig> {
}
}
#[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<OptionSmtpConfig> for Option<SmtpConfig> {
}
}
#[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 {
+3 -3
View File
@@ -128,17 +128,17 @@ pub(crate) async fn configure(path: PathBuf) -> Result<TomlConfig> {
});
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| {