mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-20 07:01:12 +00:00
move attachment, body and header to dedicated folders
This commit is contained in:
parent
cdce6c0bf2
commit
474fae06ee
|
@ -1,4 +1,4 @@
|
||||||
//! Module related to mailboxes.
|
//! Module related to mailbox.
|
||||||
|
|
||||||
pub mod arg;
|
pub mod arg;
|
||||||
pub mod entity;
|
pub mod entity;
|
||||||
|
|
|
@ -226,22 +226,12 @@ fn page_arg<'a>() -> Arg<'a, 'a> {
|
||||||
.default_value("0")
|
.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.
|
/// Message subcommands.
|
||||||
pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
||||||
vec![
|
vec![
|
||||||
msg::flag::arg::subcmds(),
|
msg::flag::arg::subcmds(),
|
||||||
msg::tpl::arg::subcmds(),
|
msg::tpl::arg::subcmds(),
|
||||||
|
msg::attachment::arg::subcmds(),
|
||||||
vec![
|
vec![
|
||||||
SubCommand::with_name("list")
|
SubCommand::with_name("list")
|
||||||
.aliases(&["lst", "l"])
|
.aliases(&["lst", "l"])
|
||||||
|
@ -262,7 +252,7 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
||||||
),
|
),
|
||||||
SubCommand::with_name("write")
|
SubCommand::with_name("write")
|
||||||
.about("Writes a new message")
|
.about("Writes a new message")
|
||||||
.arg(attachment_arg()),
|
.arg(msg::attachment::arg::path_arg()),
|
||||||
SubCommand::with_name("send")
|
SubCommand::with_name("send")
|
||||||
.about("Sends a raw message")
|
.about("Sends a raw message")
|
||||||
.arg(Arg::with_name("message").raw(true).last(true)),
|
.arg(Arg::with_name("message").raw(true).last(true)),
|
||||||
|
@ -287,19 +277,16 @@ pub fn subcmds<'a>() -> Vec<App<'a, 'a>> {
|
||||||
.long("raw")
|
.long("raw")
|
||||||
.short("r"),
|
.short("r"),
|
||||||
),
|
),
|
||||||
SubCommand::with_name("attachments")
|
|
||||||
.about("Downloads all message attachments")
|
|
||||||
.arg(uid_arg()),
|
|
||||||
SubCommand::with_name("reply")
|
SubCommand::with_name("reply")
|
||||||
.about("Answers to a message")
|
.about("Answers to a message")
|
||||||
.arg(uid_arg())
|
.arg(uid_arg())
|
||||||
.arg(reply_all_arg())
|
.arg(reply_all_arg())
|
||||||
.arg(attachment_arg()),
|
.arg(msg::attachment::arg::path_arg()),
|
||||||
SubCommand::with_name("forward")
|
SubCommand::with_name("forward")
|
||||||
.aliases(&["fwd"])
|
.aliases(&["fwd"])
|
||||||
.about("Forwards a message")
|
.about("Forwards a message")
|
||||||
.arg(uid_arg())
|
.arg(uid_arg())
|
||||||
.arg(attachment_arg()),
|
.arg(msg::attachment::arg::path_arg()),
|
||||||
SubCommand::with_name("copy")
|
SubCommand::with_name("copy")
|
||||||
.aliases(&["cp"])
|
.aliases(&["cp"])
|
||||||
.about("Copies a message to the targetted mailbox")
|
.about("Copies a message to the targetted mailbox")
|
||||||
|
|
24
src/domain/msg/attachment/arg.rs
Normal file
24
src/domain/msg/attachment/arg.rs
Normal 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)
|
||||||
|
}
|
4
src/domain/msg/attachment/mod.rs
Normal file
4
src/domain/msg/attachment/mod.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
//! Module related to message attachment.
|
||||||
|
|
||||||
|
pub mod arg;
|
||||||
|
pub mod entity;
|
1
src/domain/msg/body/mod.rs
Normal file
1
src/domain/msg/body/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod entity;
|
|
@ -3,10 +3,12 @@ use imap::types::{Fetch, Flag, ZeroCopy};
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use mailparse;
|
use mailparse;
|
||||||
|
|
||||||
use super::{attachment::Attachment, body::Body, headers::Headers};
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::entity::Account,
|
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},
|
ui::table::{Cell, Row, Table},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,10 @@ use crate::{
|
||||||
mbox::entity::Mbox,
|
mbox::entity::Mbox,
|
||||||
msg::{
|
msg::{
|
||||||
self,
|
self,
|
||||||
body::Body,
|
body::entity::Body,
|
||||||
entity::{Msg, Msgs},
|
entity::{Msg, MsgSerialized, Msgs},
|
||||||
|
flag::entity::Flags,
|
||||||
|
header::entity::Headers,
|
||||||
},
|
},
|
||||||
smtp::service::SmtpServiceInterface,
|
smtp::service::SmtpServiceInterface,
|
||||||
},
|
},
|
||||||
|
@ -27,8 +29,6 @@ use crate::{
|
||||||
ui::choice::{self, PostEditChoice},
|
ui::choice::{self, PostEditChoice},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{entity::MsgSerialized, flag::entity::Flags, headers::Headers};
|
|
||||||
|
|
||||||
// TODO: move this function to the right folder
|
// TODO: move this function to the right folder
|
||||||
fn msg_interaction<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
fn msg_interaction<ImapService: ImapServiceInterface, SmtpService: SmtpServiceInterface>(
|
||||||
output: &OutputService,
|
output: &OutputService,
|
||||||
|
|
1
src/domain/msg/header/mod.rs
Normal file
1
src/domain/msg/header/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod entity;
|
|
@ -30,7 +30,7 @@ pub mod attachment;
|
||||||
|
|
||||||
/// This module is used in the `Msg` struct, which should represent the headers
|
/// This module is used in the `Msg` struct, which should represent the headers
|
||||||
/// fields like `To:` and `From:`.
|
/// 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
|
/// 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`.
|
/// a msg; The part where you're writing some text like `Dear Mr. LMAO`.
|
||||||
|
|
|
@ -13,9 +13,9 @@ use crate::{
|
||||||
domain::{
|
domain::{
|
||||||
imap::service::ImapServiceInterface,
|
imap::service::ImapServiceInterface,
|
||||||
msg::{
|
msg::{
|
||||||
body::Body,
|
body::entity::Body,
|
||||||
entity::{Msg, MsgSerialized},
|
entity::{Msg, MsgSerialized},
|
||||||
headers::Headers,
|
header::entity::Headers,
|
||||||
tpl::arg::Tpl,
|
tpl::arg::Tpl,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue