62 lines
1.7 KiB
Rust
62 lines
1.7 KiB
Rust
use std::path::PathBuf;
|
|
|
|
use clap::{Args, Parser, Subcommand};
|
|
|
|
#[derive(Parser)]
|
|
#[clap(author, version, about, long_about = None)]
|
|
pub(crate) struct Cli {
|
|
#[clap(subcommand)]
|
|
pub command: Command,
|
|
}
|
|
|
|
#[derive(Args)]
|
|
pub(crate) struct ImapSettings {
|
|
#[clap(short, long, value_parser)]
|
|
pub server: String,
|
|
#[clap(long, value_parser, default_value_t = 993)]
|
|
pub port: u16,
|
|
#[clap(short, long, value_parser)]
|
|
pub username: String,
|
|
#[clap(short, long, value_parser)]
|
|
pub password: String,
|
|
}
|
|
|
|
#[derive(Args)]
|
|
pub(crate) struct FeedBuilderSettings {
|
|
/// Host name hosting the feed
|
|
pub hostname: String,
|
|
/// Feed file
|
|
#[clap(value_parser, default_value = "output/feed.xml")]
|
|
pub filename: PathBuf,
|
|
/// Create an HTML file for each message
|
|
#[clap(short, long, value_parser, default_value_t = false)]
|
|
pub include_html: bool,
|
|
}
|
|
|
|
#[derive(Subcommand)]
|
|
pub(crate) enum Command {
|
|
/// Fetch emails from an IMAP server
|
|
FetchFromImap(ImapSettings),
|
|
/// Fetch an email from a .eml file
|
|
FetchFromFile {
|
|
#[clap(value_parser)]
|
|
filename: PathBuf,
|
|
},
|
|
/// Build an ATOM feed containing the full contents of the email
|
|
BuildFeed(FeedBuilderSettings),
|
|
/// Exports the emails as HTML files
|
|
ExportHtml {
|
|
/// The directory in which the emails will be stored
|
|
#[clap(value_parser, default_value = "output/")]
|
|
directory: PathBuf,
|
|
},
|
|
/// Fetches and exports all mails from an IMAP mailbox. Requires configuration
|
|
FetchAndExport {
|
|
/// The directory in which the output will be stored
|
|
#[clap(value_parser, default_value = "output/")]
|
|
directory: PathBuf,
|
|
},
|
|
/// Update to the latest version
|
|
Update,
|
|
}
|