summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2020-04-25 11:50:34 +0200
committerMatthias Beyer <mail@beyermatthias.de>2020-06-01 14:01:39 +0200
commitc686be824ec7feff49b8c8cb916a6462c0aff6ef (patch)
treea70b290a494e78e02573df45ae9916fa14c3a919
parentdc56e71afea2af8f107d04a6822bb517795ca480 (diff)
Add getters with "add_getters_setters" for MailConfig
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/domain/imag-mail/Cargo.toml1
-rw-r--r--bin/domain/imag-mail/src/config.rs57
-rw-r--r--bin/domain/imag-mail/src/lib.rs1
3 files changed, 34 insertions, 25 deletions
diff --git a/bin/domain/imag-mail/Cargo.toml b/bin/domain/imag-mail/Cargo.toml
index 77879b59..5cff3bff 100644
--- a/bin/domain/imag-mail/Cargo.toml
+++ b/bin/domain/imag-mail/Cargo.toml
@@ -30,6 +30,7 @@ serde_derive = "1"
chrono = "0.4"
email-format = "0.8"
maildir = "0.4"
+add_getters_setters = "1.1"
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
diff --git a/bin/domain/imag-mail/src/config.rs b/bin/domain/imag-mail/src/config.rs
index aaa47013..82e84585 100644
--- a/bin/domain/imag-mail/src/config.rs
+++ b/bin/domain/imag-mail/src/config.rs
@@ -25,31 +25,39 @@ use clap::ArgMatches;
use libimagrt::runtime::Runtime;
-#[derive(Debug, Serialize, Deserialize, Partial)]
+#[derive(Debug, Serialize, Deserialize, Partial, AddGetter)]
#[location = "mail"]
pub struct MailConfig {
#[serde(rename = "list_format")]
+ #[get]
list_format: String,
#[serde(rename = "notmuch_database")]
+ #[get]
notmuch_database_path: PathBuf,
#[serde(rename = "import_tag")]
+ #[get]
import_tag: Option<String>,
#[serde(rename = "import_notmuch_tags")]
+ #[get]
import_notmuch_tags: bool,
#[serde(rename = "edit_headers")]
+ #[get]
edit_headers: bool,
#[serde(rename = "default_template")]
+ #[get]
default_template: String,
#[serde(rename = "header_template")]
+ #[get]
header_template: String,
#[serde(rename = "from_address")]
+ #[get]
from_address: String,
/// The location where the mail is stored after it is written, but before it is sent.
@@ -58,38 +66,47 @@ pub struct MailConfig {
/// The mail-send-script should pick up each mail in here and process it.
/// Not to be confused with "drafts" which are not intended for sending yet.
#[serde(rename = "outgoing_maildir")]
+ #[get]
outgoing_maildir: PathBuf,
/// Path script to run before writing outgoing mail to outgoing_maildir (optional)
#[serde(rename = "pre_outgoing")]
+ #[get]
pre_outgoing: Option<PathBuf>,
/// Path script to run after writing outgoing mail to outgoing_maildir (optional)
#[serde(rename = "post_outgoing")]
+ #[get]
post_outgoing: Option<PathBuf>,
/// The location where to put drafted mails
#[serde(rename = "draft_maildir")]
+ #[get]
draft_maildir: PathBuf,
/// Path script to run before writing draft mail to draft_maildir (optional)
#[serde(rename = "pre_draft")]
+ #[get]
pre_draft: Option<PathBuf>,
/// Path script to run after writing draft mail to draft_maildir (optional)
#[serde(rename = "post_draft")]
+ #[get]
post_draft: Option<PathBuf>,
/// The location where to put sent mails
#[serde(rename = "sent_maildir")]
+ #[get]
sent_maildir: PathBuf,
/// Path script to run before writing mail to sent_maildir (optional)
#[serde(rename = "pre_sent")]
+ #[get]
pre_sent: Option<PathBuf>,
/// Path script to run after writing mail to sent_maildir (optional)
#[serde(rename = "post_sent")]
+ #[get]
post_sent: Option<PathBuf>,
@@ -103,34 +120,42 @@ pub struct MailConfig {
///
/// STDERR of the script is logged by imag.
#[serde(rename = "recv_script")]
+ #[get]
recv_script: PathBuf,
/// Whether to show output for each mail
+ #[get]
recv_output: bool,
/// Output format for each mail
+ #[get]
recv_output_format: Option<String>,
/// Whether to show summary output after receiving
+ #[get]
recv_output_summary: bool,
/// Summary output format after receiving
+ #[get]
recv_output_summary_format: Option<String>,
/// Script to be invoked before recving. (optional)
///
/// STDERR of the script is logged by imag.
#[serde(rename = "pre_recv_script")]
+ #[get]
pre_recv_script: Option<PathBuf>,
/// Script to be invoked after recving. (optional)
///
/// STDERR of the script is logged by imag.
#[serde(rename = "post_recv_script")]
+ #[get]
post_recv_script: Option<PathBuf>,
/// Whether to automatically import new emails
#[serde(rename = "auto_import")]
+ #[get]
auto_import: bool,
//
@@ -149,9 +174,12 @@ pub struct MailConfig {
///
/// STDERR of the script is logged by imag.
#[serde(rename = "send_script")]
+ #[get]
send_script: PathBuf,
/// Whether to show a progress bar when sending
+ #[serde(rename = "send_progress")]
+ #[get]
send_progress: bool,
/// If false, the invokation of the send scripts are chained. If one fails, the chain is
@@ -160,6 +188,7 @@ pub struct MailConfig {
/// If true, the script is invoked in parallel for all mails. If one fails, the others are still
/// running.
#[serde(rename = "send_parallel")]
+ #[get]
send_parallel: bool,
/// Script to be invoked before sending. (optional)
@@ -170,6 +199,7 @@ pub struct MailConfig {
///
/// STDERR of the script is logged by imag.
#[serde(rename = "pre_send_script")]
+ #[get]
pre_send_script: Option<PathBuf>,
/// Script to be invoked after sending. (optional)
@@ -178,6 +208,7 @@ pub struct MailConfig {
///
/// STDERR of the script is logged by imag.
#[serde(rename = "post_send_script")]
+ #[get]
post_send_script: Option<PathBuf>,
}
@@ -210,29 +241,5 @@ impl MailConfig {
self.notmuch_database_path.clone()
}
}
-
- pub fn get_import_tag(&self) -> Option<&String> {
- self.import_tag.as_ref()
- }
-
- pub fn get_import_notmuch_tags(&self) -> bool {
- self.import_notmuch_tags
- }
-
- pub fn get_edit_headers(&self) -> bool {
- self.edit_headers
- }
-
- pub fn get_default_template(&self) -> &String {
- &self.default_template
- }
-
- pub fn get_header_template(&self) -> &String {
- &self.header_template
- }
-
- pub fn get_from_address(&self) -> &String {
- &self.from_address
- }
}
diff --git a/bin/domain/imag-mail/src/lib.rs b/bin/domain/imag-mail/src/lib.rs
index 2ef1da37..a892d0b5 100644
--- a/bin/domain/imag-mail/src/lib.rs
+++ b/bin/domain/imag-mail/src/lib.rs
@@ -47,6 +47,7 @@ extern crate chrono;
extern crate email_format;
extern crate maildir;
#[macro_use] extern crate serde_derive;
+#[macro_use] extern crate add_getters_setters;
extern crate libimagrt;
extern crate libimagmail;