mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-20 07:01:12 +00:00
make notmuch optional via cargo features (#303)
This commit is contained in:
parent
00e2524640
commit
a2616fc1bd
|
@ -32,7 +32,7 @@ log = "0.4.14"
|
||||||
maildir = "0.6.0"
|
maildir = "0.6.0"
|
||||||
mailparse = "0.13.6"
|
mailparse = "0.13.6"
|
||||||
native-tls = "0.2.8"
|
native-tls = "0.2.8"
|
||||||
notmuch = "0.7.1"
|
notmuch = { version = "0.7.1", optional = true }
|
||||||
regex = "1.5.4"
|
regex = "1.5.4"
|
||||||
rfc2047-decoder = "0.1.2"
|
rfc2047-decoder = "0.1.2"
|
||||||
serde = { version = "1.0.118", features = ["derive"] }
|
serde = { version = "1.0.118", features = ["derive"] }
|
||||||
|
|
|
@ -70,6 +70,7 @@ impl<'a> AccountConfig {
|
||||||
DeserializedAccountConfig::Maildir(account) => {
|
DeserializedAccountConfig::Maildir(account) => {
|
||||||
account.default.unwrap_or_default()
|
account.default.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
DeserializedAccountConfig::Notmuch(account) => {
|
DeserializedAccountConfig::Notmuch(account) => {
|
||||||
account.default.unwrap_or_default()
|
account.default.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
@ -177,6 +178,7 @@ impl<'a> AccountConfig {
|
||||||
maildir_dir: shellexpand::full(&config.maildir_dir)?.to_string().into(),
|
maildir_dir: shellexpand::full(&config.maildir_dir)?.to_string().into(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
DeserializedAccountConfig::Notmuch(config) => {
|
DeserializedAccountConfig::Notmuch(config) => {
|
||||||
BackendConfig::Notmuch(NotmuchBackendConfig {
|
BackendConfig::Notmuch(NotmuchBackendConfig {
|
||||||
notmuch_database_dir: shellexpand::full(&config.notmuch_database_dir)?
|
notmuch_database_dir: shellexpand::full(&config.notmuch_database_dir)?
|
||||||
|
@ -311,6 +313,7 @@ impl<'a> AccountConfig {
|
||||||
pub enum BackendConfig {
|
pub enum BackendConfig {
|
||||||
Imap(ImapBackendConfig),
|
Imap(ImapBackendConfig),
|
||||||
Maildir(MaildirBackendConfig),
|
Maildir(MaildirBackendConfig),
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
Notmuch(NotmuchBackendConfig),
|
Notmuch(NotmuchBackendConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,6 +353,7 @@ pub struct MaildirBackendConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Represents the Notmuch backend.
|
/// Represents the Notmuch backend.
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct NotmuchBackendConfig {
|
pub struct NotmuchBackendConfig {
|
||||||
/// Represents the Notmuch database path.
|
/// Represents the Notmuch database path.
|
||||||
|
|
|
@ -11,6 +11,7 @@ pub trait ToDeserializedBaseAccountConfig {
|
||||||
pub enum DeserializedAccountConfig {
|
pub enum DeserializedAccountConfig {
|
||||||
Imap(DeserializedImapAccountConfig),
|
Imap(DeserializedImapAccountConfig),
|
||||||
Maildir(DeserializedMaildirAccountConfig),
|
Maildir(DeserializedMaildirAccountConfig),
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
Notmuch(DeserializedNotmuchAccountConfig),
|
Notmuch(DeserializedNotmuchAccountConfig),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +20,7 @@ impl ToDeserializedBaseAccountConfig for DeserializedAccountConfig {
|
||||||
match self {
|
match self {
|
||||||
Self::Imap(config) => config.to_base(),
|
Self::Imap(config) => config.to_base(),
|
||||||
Self::Maildir(config) => config.to_base(),
|
Self::Maildir(config) => config.to_base(),
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
Self::Notmuch(config) => config.to_base(),
|
Self::Notmuch(config) => config.to_base(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,6 +124,7 @@ make_account_config!(
|
||||||
|
|
||||||
make_account_config!(DeserializedMaildirAccountConfig, maildir_dir: String);
|
make_account_config!(DeserializedMaildirAccountConfig, maildir_dir: String);
|
||||||
|
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
make_account_config!(
|
make_account_config!(
|
||||||
DeserializedNotmuchAccountConfig,
|
DeserializedNotmuchAccountConfig,
|
||||||
notmuch_database_dir: String
|
notmuch_database_dir: String
|
||||||
|
|
|
@ -76,7 +76,9 @@ pub mod backends {
|
||||||
pub use maildir_flag::*;
|
pub use maildir_flag::*;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
pub use self::notmuch::*;
|
pub use self::notmuch::*;
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
pub mod notmuch {
|
pub mod notmuch {
|
||||||
pub mod notmuch_backend;
|
pub mod notmuch_backend;
|
||||||
pub use notmuch_backend::*;
|
pub use notmuch_backend::*;
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::{convert::TryFrom, env};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use himalaya::{
|
use himalaya::{
|
||||||
backends::{imap_arg, imap_handler, Backend, ImapBackend, MaildirBackend, NotmuchBackend},
|
backends::{imap_arg, imap_handler, Backend, ImapBackend, MaildirBackend},
|
||||||
compl::{compl_arg, compl_handler},
|
compl::{compl_arg, compl_handler},
|
||||||
config::{
|
config::{
|
||||||
account_args, config_args, AccountConfig, BackendConfig, DeserializedConfig,
|
account_args, config_args, AccountConfig, BackendConfig, DeserializedConfig,
|
||||||
|
@ -15,6 +15,9 @@ use himalaya::{
|
||||||
smtp::LettreService,
|
smtp::LettreService,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
|
use himalaya::backends::NotmuchBackend;
|
||||||
|
|
||||||
fn create_app<'a>() -> clap::App<'a, 'a> {
|
fn create_app<'a>() -> clap::App<'a, 'a> {
|
||||||
clap::App::new(env!("CARGO_PKG_NAME"))
|
clap::App::new(env!("CARGO_PKG_NAME"))
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
.version(env!("CARGO_PKG_VERSION"))
|
||||||
|
@ -48,6 +51,7 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
let mut imap;
|
let mut imap;
|
||||||
let mut maildir;
|
let mut maildir;
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
let mut notmuch;
|
let mut notmuch;
|
||||||
let backend: Box<&mut dyn Backend> = match backend_config {
|
let backend: Box<&mut dyn Backend> = match backend_config {
|
||||||
BackendConfig::Imap(ref imap_config) => {
|
BackendConfig::Imap(ref imap_config) => {
|
||||||
|
@ -58,6 +62,7 @@ fn main() -> Result<()> {
|
||||||
maildir = MaildirBackend::new(&account_config, maildir_config);
|
maildir = MaildirBackend::new(&account_config, maildir_config);
|
||||||
Box::new(&mut maildir)
|
Box::new(&mut maildir)
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
BackendConfig::Notmuch(ref notmuch_config) => {
|
BackendConfig::Notmuch(ref notmuch_config) => {
|
||||||
notmuch = NotmuchBackend::new(&account_config, notmuch_config)?;
|
notmuch = NotmuchBackend::new(&account_config, notmuch_config)?;
|
||||||
Box::new(&mut notmuch)
|
Box::new(&mut notmuch)
|
||||||
|
@ -90,6 +95,7 @@ fn main() -> Result<()> {
|
||||||
let mut printer = StdoutPrinter::try_from(m.value_of("output"))?;
|
let mut printer = StdoutPrinter::try_from(m.value_of("output"))?;
|
||||||
let mut imap;
|
let mut imap;
|
||||||
let mut maildir;
|
let mut maildir;
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
let mut notmuch;
|
let mut notmuch;
|
||||||
let backend: Box<&mut dyn Backend> = match backend_config {
|
let backend: Box<&mut dyn Backend> = match backend_config {
|
||||||
BackendConfig::Imap(ref imap_config) => {
|
BackendConfig::Imap(ref imap_config) => {
|
||||||
|
@ -100,6 +106,7 @@ fn main() -> Result<()> {
|
||||||
maildir = MaildirBackend::new(&account_config, maildir_config);
|
maildir = MaildirBackend::new(&account_config, maildir_config);
|
||||||
Box::new(&mut maildir)
|
Box::new(&mut maildir)
|
||||||
}
|
}
|
||||||
|
#[cfg(feature = "notmuch")]
|
||||||
BackendConfig::Notmuch(ref notmuch_config) => {
|
BackendConfig::Notmuch(ref notmuch_config) => {
|
||||||
notmuch = NotmuchBackend::new(&account_config, notmuch_config)?;
|
notmuch = NotmuchBackend::new(&account_config, notmuch_config)?;
|
||||||
Box::new(&mut notmuch)
|
Box::new(&mut notmuch)
|
||||||
|
|
Loading…
Reference in a new issue