diff --git a/src/config/arg.rs b/src/config/arg.rs new file mode 100644 index 0000000..bc498d6 --- /dev/null +++ b/src/config/arg.rs @@ -0,0 +1,10 @@ +use clap::Arg; + +/// Config argument. +pub fn path_arg<'a>() -> Arg<'a, 'a> { + Arg::with_name("config") + .long("config") + .short("c") + .help("Forces a specific config path") + .value_name("PATH") +} diff --git a/src/config/cli.rs b/src/config/cli.rs deleted file mode 100644 index edc2d2d..0000000 --- a/src/config/cli.rs +++ /dev/null @@ -1,16 +0,0 @@ -use clap::Arg; - -pub fn config_args<'a>() -> Vec> { - vec![ - Arg::with_name("config") - .long("config") - .short("c") - .help("Forces a specific config path") - .value_name("PATH"), - Arg::with_name("account") - .long("account") - .short("a") - .help("Selects a specific account") - .value_name("NAME"), - ] -} diff --git a/src/domain/config/entity.rs b/src/config/entity.rs similarity index 100% rename from src/domain/config/entity.rs rename to src/config/entity.rs diff --git a/src/config/mod.rs b/src/config/mod.rs index 4f77372..887e02c 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1 +1,4 @@ -pub mod cli; +//! Modules related to the user's configuration. + +pub mod arg; +pub mod entity; diff --git a/src/domain/account/arg.rs b/src/domain/account/arg.rs new file mode 100644 index 0000000..064a95c --- /dev/null +++ b/src/domain/account/arg.rs @@ -0,0 +1,10 @@ +use clap::Arg; + +/// Account argument. +pub fn name_arg<'a>() -> Arg<'a, 'a> { + Arg::with_name("account") + .long("account") + .short("a") + .help("Selects a specific account") + .value_name("NAME") +} diff --git a/src/domain/account/entity.rs b/src/domain/account/entity.rs index bc6a24b..90d0cac 100644 --- a/src/domain/account/entity.rs +++ b/src/domain/account/entity.rs @@ -3,7 +3,7 @@ use lettre::transport::smtp::authentication::Credentials as SmtpCredentials; use log::{debug, trace}; use std::{convert::TryFrom, env, fs, path::PathBuf}; -use crate::{domain::config::entity::Config, output::utils::run_cmd}; +use crate::{config::entity::Config, output::utils::run_cmd}; const DEFAULT_PAGE_SIZE: usize = 10; const DEFAULT_SIG_DELIM: &str = "-- \n"; diff --git a/src/domain/account/mod.rs b/src/domain/account/mod.rs index 3dbf381..f65c797 100644 --- a/src/domain/account/mod.rs +++ b/src/domain/account/mod.rs @@ -1,3 +1,4 @@ //! Modules related to the user's accounts. +pub mod arg; pub mod entity; diff --git a/src/domain/config/mod.rs b/src/domain/config/mod.rs deleted file mode 100644 index 1f827b8..0000000 --- a/src/domain/config/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -//! Modules related to the user's configuration. - -pub mod entity; diff --git a/src/domain/imap/handler.rs b/src/domain/imap/handler.rs index 8aa2545..c756085 100644 --- a/src/domain/imap/handler.rs +++ b/src/domain/imap/handler.rs @@ -4,7 +4,7 @@ use anyhow::Result; -use crate::domain::{config::entity::Config, imap::service::ImapServiceInterface}; +use crate::{config::entity::Config, domain::imap::service::ImapServiceInterface}; /// Notify handler. pub fn notify( diff --git a/src/domain/imap/service.rs b/src/domain/imap/service.rs index d8df6a4..7a2d6d9 100644 --- a/src/domain/imap/service.rs +++ b/src/domain/imap/service.rs @@ -8,11 +8,13 @@ use log::{debug, trace}; use native_tls::{self, TlsConnector, TlsStream}; use std::{collections::HashSet, convert::TryFrom, iter::FromIterator, net::TcpStream}; -use crate::domain::{ - account::entity::Account, +use crate::{ config::entity::Config, - mbox::entity::Mbox, - msg::{entity::Msg, flag::entity::Flags}, + domain::{ + account::entity::Account, + mbox::entity::Mbox, + msg::{entity::Msg, flag::entity::Flags}, + }, }; type ImapSession = imap::Session>; diff --git a/src/domain/mod.rs b/src/domain/mod.rs index c3446e0..1636e05 100644 --- a/src/domain/mod.rs +++ b/src/domain/mod.rs @@ -1,7 +1,6 @@ //! Domain-specific modules. pub mod account; -pub mod config; pub mod imap; pub mod mbox; pub mod msg; diff --git a/src/main.rs b/src/main.rs index 64b7ff1..b3b361b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,10 +6,9 @@ use url::Url; use himalaya::{ compl, - config::cli::config_args, + config::{self, entity::Config}, domain::{ - account::entity::Account, - config::entity::Config, + account::{self, entity::Account}, imap::{self, service::ImapService}, mbox::{self, entity::Mbox}, msg, @@ -24,7 +23,8 @@ fn create_app<'a>() -> clap::App<'a, 'a> { .about(env!("CARGO_PKG_DESCRIPTION")) .author(env!("CARGO_PKG_AUTHORS")) .args(&output_args()) - .args(&config_args()) + .arg(config::arg::path_arg()) + .arg(account::arg::name_arg()) .arg(mbox::arg::source_arg()) .subcommands(compl::arg::subcmds()) .subcommands(imap::arg::subcmds())