move attachment, body and header to dedicated folders

This commit is contained in:
Clément DOUIN 2021-09-19 10:14:25 +02:00
parent cdce6c0bf2
commit 474fae06ee
No known key found for this signature in database
GPG key ID: 69C9B9CFFDEE2DEF
13 changed files with 46 additions and 27 deletions

View file

@ -1,4 +1,4 @@
//! Module related to mailboxes.
//! Module related to mailbox.
pub mod arg;
pub mod entity;

View file

@ -226,22 +226,12 @@ fn page_arg<'a>() -> Arg<'a, 'a> {
.default_value("0")
}
/// Message attachment argument.
/// TODO: move to attachment folder
fn attachment_arg<'a>() -> Arg<'a, 'a> {
Arg::with_name("attachments")
.help("Adds attachment to the message")
.short("a")
.long("attachment")
.value_name("PATH")
.multiple(true)
}
/// Message subcommands.
pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
vec![
msg::flag::arg::subcmds(),
msg::tpl::arg::subcmds(),
msg::attachment::arg::subcmds(),
vec![
SubCommand::with_name("list")
.aliases(&["lst", "l"])
@ -262,7 +252,7 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
),
SubCommand::with_name("write")
.about("Writes a new message")
.arg(attachment_arg()),
.arg(msg::attachment::arg::path_arg()),
SubCommand::with_name("send")
.about("Sends a raw message")
.arg(Arg::with_name("message").raw(true).last(true)),
@ -287,19 +277,16 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
.long("raw")
.short("r"),
),
SubCommand::with_name("attachments")
.about("Downloads all message attachments")
.arg(uid_arg()),
SubCommand::with_name("reply")
.about("Answers to a message")
.arg(uid_arg())
.arg(reply_all_arg())
.arg(attachment_arg()),
.arg(msg::attachment::arg::path_arg()),
SubCommand::with_name("forward")
.aliases(&["fwd"])
.about("Forwards a message")
.arg(uid_arg())
.arg(attachment_arg()),
.arg(msg::attachment::arg::path_arg()),
SubCommand::with_name("copy")
.aliases(&["cp"])
.about("Copies a message to the targetted mailbox")

View file

@ -0,0 +1,24 @@
//! Module related to message attachment CLI.
//!
//! This module provides arguments related to message attachment.
use clap::{App, Arg, SubCommand};
use crate::domain::msg;
/// Message attachment subcommands.
pub(crate) fn subcmds<'a>() -> Vec<App<'a, 'a>> {
vec![SubCommand::with_name("attachments")
.about("Downloads all message attachments")
.arg(msg::arg::uid_arg())]
}
/// Message attachment path argument.
pub(crate) fn path_arg<'a>() -> Arg<'a, 'a> {
Arg::with_name("attachments")
.help("Adds attachment to the message")
.short("a")
.long("attachment")
.value_name("PATH")
.multiple(true)
}

View file

@ -0,0 +1,4 @@
//! Module related to message attachment.
pub mod arg;
pub mod entity;

View file

@ -0,0 +1 @@
pub mod entity;

View file

@ -3,10 +3,12 @@ use imap::types::{Fetch, Flag, ZeroCopy};
use log::debug;
use mailparse;
use super::{attachment::Attachment, body::Body, headers::Headers};
use crate::{
config::entity::Account,
domain::msg::flag::entity::Flags,
domain::msg::{
attachment::entity::Attachment, body::entity::Body, flag::entity::Flags,
header::entity::Headers,
},
ui::table::{Cell, Row, Table},
};

View file

@ -18,8 +18,10 @@ use crate::{
mbox::entity::Mbox,
msg::{
self,
body::Body,
entity::{Msg, Msgs},
body::entity::Body,
entity::{Msg, MsgSerialized, Msgs},
flag::entity::Flags,
header::entity::Headers,
},
smtp::service::SmtpServiceInterface,
},
@ -27,8 +29,6 @@ use crate::{
ui::choice::{self, PostEditChoice},
};
use super::{entity::MsgSerialized, flag::entity::Flags, headers::Headers};
// TODO: move this function to the right folder
fn msg_interaction<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
output: &OutputService,

View file

@ -0,0 +1 @@
pub mod entity;

View file

@ -30,7 +30,7 @@ pub mod attachment;
/// This module is used in the `Msg` struct, which should represent the headers
/// fields like `To:` and `From:`.
pub mod headers;
pub mod header;
/// This module is used in the `Msg` struct, which should represent the body of
/// a msg; The part where you're writing some text like `Dear Mr. LMAO`.

View file

@ -13,9 +13,9 @@ use crate::{
domain::{
imap::service::ImapServiceInterface,
msg::{
body::Body,
body::entity::Body,
entity::{Msg, MsgSerialized},
headers::Headers,
header::entity::Headers,
tpl::arg::Tpl,
},
},