remove config from domain module

This commit is contained in:
Clément DOUIN 2021-09-17 18:30:17 +02:00
parent 54493540b4
commit 94f7dd5b05
No known key found for this signature in database
GPG key ID: 69C9B9CFFDEE2DEF
12 changed files with 37 additions and 31 deletions

10
src/config/arg.rs Normal file
View file

@ -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")
}

View file

@ -1,16 +0,0 @@
use clap::Arg;
pub fn config_args<'a>() -> Vec<Arg<'a, 'a>> {
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"),
]
}

View file

@ -1 +1,4 @@
pub mod cli;
//! Modules related to the user's configuration.
pub mod arg;
pub mod entity;

10
src/domain/account/arg.rs Normal file
View file

@ -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")
}

View file

@ -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";

View file

@ -1,3 +1,4 @@
//! Modules related to the user's accounts.
pub mod arg;
pub mod entity;

View file

@ -1,3 +0,0 @@
//! Modules related to the user's configuration.
pub mod entity;

View file

@ -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<ImapService: ImapServiceInterface>(

View file

@ -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<TlsStream<TcpStream>>;

View file

@ -1,7 +1,6 @@
//! Domain-specific modules.
pub mod account;
pub mod config;
pub mod imap;
pub mod mbox;
pub mod msg;

View file

@ -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())