diff --git a/Cargo.lock b/Cargo.lock
index 7474983..761e576 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -794,12 +794,9 @@ dependencies = [
[[package]]
name = "heck"
-version = "0.3.3"
+version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
-dependencies = [
- "unicode-segmentation",
-]
+checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
[[package]]
name = "hermit-abi"
@@ -1832,8 +1829,7 @@ dependencies = [
[[package]]
name = "structopt-derive"
version = "0.4.18"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
+source = "git+https://github.com/epilys/structopt-derive-manpage#2861b6318cfe9fce0a7edc61e202e522b036616c"
dependencies = [
"heck",
"proc-macro-error",
diff --git a/Cargo.toml b/Cargo.toml
index c867f8e..4fcba3b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,3 +5,6 @@ members = [
"rest-http",
"archive-http",
]
+
+[patch.crates-io]
+structopt-derive = { git = "https://github.com/epilys/structopt-derive-manpage" }
diff --git a/cli/build.rs b/cli/build.rs
new file mode 100644
index 0000000..9e4c27a
--- /dev/null
+++ b/cli/build.rs
@@ -0,0 +1,43 @@
+/*
+ * This file is part of mailpot
+ *
+ * Copyright 2020 - Manos Pitsidianakis
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+use std::io::Write;
+use std::process::Command;
+
+fn main() {
+ println!("cargo:rerun-if-changed=../docs/command.mdoc");
+ println!("cargo:rerun-if-changed=../docs/list.mdoc");
+ println!("cargo:rerun-if-changed=../docs/error_queue.mdoc");
+ println!("cargo:rerun-if-changed=../docs/main.mdoc");
+ println!("cargo:rerun-if-changed=../docs/header.mdoc");
+ println!("cargo:rerun-if-changed=../docs/footer.mdoc");
+ println!("cargo:rerun-if-changed=../docs/mailpot.1.m4");
+ println!("cargo:rerun-if-changed=../docs/mailpot.1");
+ println!("cargo:rerun-if-changed=../docs");
+ println!("cargo:rerun-if-changed=./src/main.rs");
+ println!("build running");
+ std::env::set_current_dir("..").expect("could not chdir('..')");
+
+ let output = Command::new("m4")
+ .arg("./docs/mailpot.1.m4")
+ .output()
+ .unwrap();
+ let mut file = std::fs::File::create("./docs/mailpot.1").unwrap();
+ file.write_all(&output.stdout).unwrap();
+}
diff --git a/cli/src/main.rs b/cli/src/main.rs
index ccce2d8..d5dc8ec 100644
--- a/cli/src/main.rs
+++ b/cli/src/main.rs
@@ -35,7 +35,10 @@ use structopt::StructOpt;
#[structopt(
name = "mailpot",
about = "mini mailing list manager",
- author = "Manos Pitsidianakis "
+ author = "Manos Pitsidianakis ",
+ manpage = "docs/main.mdoc",
+ manpage_header = "docs/header.mdoc",
+ manpage_footer = "docs/footer.mdoc"
)]
struct Opt {
/// Activate debug mode
@@ -60,6 +63,7 @@ struct Opt {
}
#[derive(Debug, StructOpt)]
+#[structopt(manpage = "docs/command.mdoc")]
enum Command {
///Prints database filesystem location
DbLocation,
@@ -107,6 +111,7 @@ enum Command {
}
#[derive(Debug, StructOpt)]
+#[structopt(manpage = "docs/error_queue.mdoc")]
enum ErrorQueueCommand {
/// List.
List,
@@ -131,6 +136,7 @@ enum ErrorQueueCommand {
}
#[derive(Debug, StructOpt)]
+#[structopt(manpage = "docs/list.mdoc")]
enum ListCommand {
/// List members of list.
Members,
diff --git a/docs/command.mdoc b/docs/command.mdoc
new file mode 100644
index 0000000..dc69c93
--- /dev/null
+++ b/docs/command.mdoc
@@ -0,0 +1,54 @@
+
+.Bl -tag -width Ds -compact -offset indent
+.It Ic db-location
+Prints database filesystem location.
+.It Ic config-location
+Prints default configuration file filesystem location.
+.It Ic dump-database
+Dumps database data to STDOUT.
+.It Ic list-lists
+Lists all registered mailing lists.
+.It Ic list
+Mailing list management.
+.It Ic create-list
+.Fl -name Ar name
+List name.
+
+.Fl -id Ar id
+List ID.
+
+.Fl -address Ar address
+List e-mail address.
+
+.Fl -description Ar description
+List description.
+
+.Fl -archive-url Ar archive-url
+List archive URL.
+
+Create new list.
+.It Ic post
+.Fl -dry-run
+.
+
+Post message from STDIN to list.
+.It Ic error-queue
+Mail that has not been handled properly end up in the error queue.
+.It Ic db-location
+Prints database filesystem location.
+.It Ic config-location
+Prints default configuration file filesystem location.
+.It Ic dump-database
+Dumps database data to STDOUT.
+.It Ic list-lists
+Lists all registered mailing lists.
+.It Ic list
+Mailing list management.
+.It Ic create-list
+Create new list.
+.It Ic post
+Post message from STDIN to list.
+.It Ic error-queue
+Mail that has not been handled properly end up in the error queue.
+.El
+.Pp
diff --git a/docs/error_queue.mdoc b/docs/error_queue.mdoc
new file mode 100644
index 0000000..e769295
--- /dev/null
+++ b/docs/error_queue.mdoc
@@ -0,0 +1,28 @@
+
+.Bl -tag -width Ds -compact -offset indent
+.It Ic list
+List.
+.It Ic print
+.Fl -index Ar index ...
+index of entry.
+
+.Fl -json
+JSON format.
+
+Print entry in RFC5322 or JSON format.
+.It Ic delete
+.Fl -index Ar index ...
+index of entry.
+
+.Fl -quiet
+Do not print in stdout.
+
+Delete entry and print it in stdout.
+.It Ic list
+List.
+.It Ic print
+Print entry in RFC5322 or JSON format.
+.It Ic delete
+Delete entry and print it in stdout.
+.El
+.Pp
diff --git a/docs/footer.mdoc b/docs/footer.mdoc
new file mode 100644
index 0000000..4d59ef6
--- /dev/null
+++ b/docs/footer.mdoc
@@ -0,0 +1,2 @@
+.Sh AUTHORS
+Manos Pitsidianakis
\ No newline at end of file
diff --git a/docs/header.mdoc b/docs/header.mdoc
new file mode 100644
index 0000000..7087e34
--- /dev/null
+++ b/docs/header.mdoc
@@ -0,0 +1,6 @@
+.Dd $Mdocdate$
+.Dt MAILPOT 1
+.Os
+.Sh NAME
+.Nm mailpot
+.Nd mini mailing list manager.
\ No newline at end of file
diff --git a/docs/list.mdoc b/docs/list.mdoc
new file mode 100644
index 0000000..31f1221
--- /dev/null
+++ b/docs/list.mdoc
@@ -0,0 +1,104 @@
+
+.Bl -tag -width Ds -compact -offset indent
+.It Ic members
+List members of list.
+.It Ic add-member
+.Fl -address Ar address
+E-mail address.
+
+.Fl -name Ar name
+Name.
+
+.Fl -digest
+Send messages as digest?.
+
+.Fl -hide-address
+Hide message from list when posting?.
+
+.Fl -receive-confirmation Ar receive-confirmation
+Hide message from list when posting? Receive confirmation email when posting?.
+
+.Fl -receive-duplicates Ar receive-duplicates
+Receive posts from list even if address exists in To or Cc header?.
+
+.Fl -receive-own-posts Ar receive-own-posts
+Receive own posts from list?.
+
+.Fl -enabled Ar enabled
+Is subscription enabled?.
+
+Add member to list.
+.It Ic remove-member
+.Fl -address Ar address
+E-mail address.
+
+Remove member from list.
+.It Ic update-membership
+Update membership info.
+.It Ic add-policy
+.Fl -announce-only
+.
+
+.Fl -subscriber-only
+.
+
+.Fl -approval-needed
+.
+
+Add policy to list.
+.It Ic remove-policy
+.Fl -pk Ar pk
+.
+
+.
+.It Ic add-list-owner
+.Fl -address Ar address
+.
+
+.Fl -name Ar name
+.
+
+Add list owner to list.
+.It Ic remove-list-owner
+.Fl -pk Ar pk
+.
+
+.
+.It Ic enable-membership
+Alias for update-membership --enabled true.
+.It Ic disable-membership
+Alias for update-membership --enabled false.
+.It Ic update
+Update mailing list details.
+.It Ic health
+Show mailing list health status.
+.It Ic info
+Show mailing list info.
+.It Ic members
+List members of list.
+.It Ic add-member
+Add member to list.
+.It Ic remove-member
+Remove member from list.
+.It Ic update-membership
+Update membership info.
+.It Ic add-policy
+Add policy to list.
+.It Ic remove-policy
+.
+.It Ic add-list-owner
+Add list owner to list.
+.It Ic remove-list-owner
+.
+.It Ic enable-membership
+Alias for update-membership --enabled true.
+.It Ic disable-membership
+Alias for update-membership --enabled false.
+.It Ic update
+Update mailing list details.
+.It Ic health
+Show mailing list health status.
+.It Ic info
+Show mailing list info.
+.El
+.Pp
diff --git a/docs/mailpot.1 b/docs/mailpot.1
new file mode 100644
index 0000000..f07db9f
--- /dev/null
+++ b/docs/mailpot.1
@@ -0,0 +1,224 @@
+.Dd $Mdocdate$
+.Dt MAILPOT 1
+.Os
+.Sh NAME
+.Nm mailpot
+.Nd mini mailing list manager.
+.Sh SYNOPSIS
+.Nm
+.Op Fl -debug
+.Op Fl -config Ar config
+.Op Fl -quiet | -q
+.Op Fl -verbose | -v
+.Op Fl -timestamp | -t Ar timestamp
+.Bl -tag -width flag -offset indent
+.It Fl -debug
+Activate debug mode.
+.It Fl -config Ar config
+Set config file.
+.It Fl -quiet | -q
+Silence all output.
+.It Fl -verbose | -v
+Verbose mode (-v, -vv, -vvv, etc).
+.It Fl -timestamp | -t Ar timestamp
+Timestamp (sec, ms, ns, none).
+.El
+
+.Sh DESCRIPTION
+This command-line tool allows you to control databases of the mailing list manager
+.Nm Ns .
+.Pp
+.Sh COMMANDS
+
+.Bl -tag -width Ds -compact -offset indent
+.It Ic db-location
+Prints database filesystem location.
+.It Ic config-location
+Prints default configuration file filesystem location.
+.It Ic dump-database
+Dumps database data to STDOUT.
+.It Ic list-lists
+Lists all registered mailing lists.
+.It Ic list
+Mailing list management.
+.It Ic create-list
+.Fl -name Ar name
+List name.
+
+.Fl -id Ar id
+List ID.
+
+.Fl -address Ar address
+List e-mail address.
+
+.Fl -description Ar description
+List description.
+
+.Fl -archive-url Ar archive-url
+List archive URL.
+
+Create new list.
+.It Ic post
+.Fl -dry-run
+.
+
+Post message from STDIN to list.
+.It Ic error-queue
+Mail that has not been handled properly end up in the error queue.
+.It Ic db-location
+Prints database filesystem location.
+.It Ic config-location
+Prints default configuration file filesystem location.
+.It Ic dump-database
+Dumps database data to STDOUT.
+.It Ic list-lists
+Lists all registered mailing lists.
+.It Ic list
+Mailing list management.
+.It Ic create-list
+Create new list.
+.It Ic post
+Post message from STDIN to list.
+.It Ic error-queue
+Mail that has not been handled properly end up in the error queue.
+.El
+.Pp
+
+.Ss list subcommands
+
+.Bl -tag -width Ds -compact -offset indent
+.It Ic members
+List members of list.
+.It Ic add-member
+.Fl -address Ar address
+E-mail address.
+
+.Fl -name Ar name
+Name.
+
+.Fl -digest
+Send messages as digest?.
+
+.Fl -hide-address
+Hide message from list when posting?.
+
+.Fl -receive-confirmation Ar receive-confirmation
+Hide message from list when posting? Receive confirmation email when posting?.
+
+.Fl -receive-duplicates Ar receive-duplicates
+Receive posts from list even if address exists in To or Cc header?.
+
+.Fl -receive-own-posts Ar receive-own-posts
+Receive own posts from list?.
+
+.Fl -enabled Ar enabled
+Is subscription enabled?.
+
+Add member to list.
+.It Ic remove-member
+.Fl -address Ar address
+E-mail address.
+
+Remove member from list.
+.It Ic update-membership
+Update membership info.
+.It Ic add-policy
+.Fl -announce-only
+.
+
+.Fl -subscriber-only
+.
+
+.Fl -approval-needed
+.
+
+Add policy to list.
+.It Ic remove-policy
+.Fl -pk Ar pk
+.
+
+.
+.It Ic add-list-owner
+.Fl -address Ar address
+.
+
+.Fl -name Ar name
+.
+
+Add list owner to list.
+.It Ic remove-list-owner
+.Fl -pk Ar pk
+.
+
+.
+.It Ic enable-membership
+Alias for update-membership --enabled true.
+.It Ic disable-membership
+Alias for update-membership --enabled false.
+.It Ic update
+Update mailing list details.
+.It Ic health
+Show mailing list health status.
+.It Ic info
+Show mailing list info.
+.It Ic members
+List members of list.
+.It Ic add-member
+Add member to list.
+.It Ic remove-member
+Remove member from list.
+.It Ic update-membership
+Update membership info.
+.It Ic add-policy
+Add policy to list.
+.It Ic remove-policy
+.
+.It Ic add-list-owner
+Add list owner to list.
+.It Ic remove-list-owner
+.
+.It Ic enable-membership
+Alias for update-membership --enabled true.
+.It Ic disable-membership
+Alias for update-membership --enabled false.
+.It Ic update
+Update mailing list details.
+.It Ic health
+Show mailing list health status.
+.It Ic info
+Show mailing list info.
+.El
+.Pp
+
+.Ss error-queue subcommands
+
+.Bl -tag -width Ds -compact -offset indent
+.It Ic list
+List.
+.It Ic print
+.Fl -index Ar index ...
+index of entry.
+
+.Fl -json
+JSON format.
+
+Print entry in RFC5322 or JSON format.
+.It Ic delete
+.Fl -index Ar index ...
+index of entry.
+
+.Fl -quiet
+Do not print in stdout.
+
+Delete entry and print it in stdout.
+.It Ic list
+List.
+.It Ic print
+Print entry in RFC5322 or JSON format.
+.It Ic delete
+Delete entry and print it in stdout.
+.El
+.Pp
+
+.Sh AUTHORS
+Manos Pitsidianakis
diff --git a/docs/mailpot.1.m4 b/docs/mailpot.1.m4
new file mode 100644
index 0000000..db67777
--- /dev/null
+++ b/docs/mailpot.1.m4
@@ -0,0 +1,14 @@
+include(`docs/header.mdoc')
+.Sh SYNOPSIS
+include(`docs/main.mdoc')
+.Sh DESCRIPTION
+This command-line tool allows you to control databases of the mailing list manager
+.Nm Ns .
+.Pp
+.Sh COMMANDS
+include(`docs/command.mdoc')
+.Ss list subcommands
+include(`docs/list.mdoc')
+.Ss error-queue subcommands
+include(`docs/error_queue.mdoc')
+include(`docs/footer.mdoc')
diff --git a/docs/main.mdoc b/docs/main.mdoc
new file mode 100644
index 0000000..04fc551
--- /dev/null
+++ b/docs/main.mdoc
@@ -0,0 +1,18 @@
+.Nm
+.Op Fl -debug
+.Op Fl -config Ar config
+.Op Fl -quiet | -q
+.Op Fl -verbose | -v
+.Op Fl -timestamp | -t Ar timestamp
+.Bl -tag -width flag -offset indent
+.It Fl -debug
+Activate debug mode.
+.It Fl -config Ar config
+Set config file.
+.It Fl -quiet | -q
+Silence all output.
+.It Fl -verbose | -v
+Verbose mode (-v, -vv, -vvv, etc).
+.It Fl -timestamp | -t Ar timestamp
+Timestamp (sec, ms, ns, none).
+.El