Files
himalaya-mail-cli/src/email/message/template/command/mod.rs
Clément DOUIN ce0b2dd8d3 build: release v1.0.0
Refs: #514
2024-12-09 12:04:15 +01:00

56 lines
1.6 KiB
Rust

mod forward;
mod reply;
mod save;
mod send;
mod write;
use clap::Subcommand;
use color_eyre::Result;
use pimalaya_tui::terminal::cli::printer::Printer;
use crate::config::TomlConfig;
use self::{
forward::TemplateForwardCommand, reply::TemplateReplyCommand, save::TemplateSaveCommand,
send::TemplateSendCommand, write::TemplateWriteCommand,
};
/// Generate, save and send message templates.
///
/// A template is an editable version of a message (headers +
/// body). It uses a specific language called MML that allows you to
/// attach file or encrypt content. This subcommand allows you manage
/// them.
///
/// Learn more about MML at: <https://crates.io/crates/mml-lib>.
#[derive(Debug, Subcommand)]
pub enum TemplateSubcommand {
#[command(aliases = ["add", "create", "new", "compose"])]
Write(TemplateWriteCommand),
#[command(arg_required_else_help = true)]
Reply(TemplateReplyCommand),
#[command(arg_required_else_help = true)]
#[command(alias = "fwd")]
Forward(TemplateForwardCommand),
#[command()]
Save(TemplateSaveCommand),
#[command()]
Send(TemplateSendCommand),
}
impl TemplateSubcommand {
pub async fn execute(self, printer: &mut impl Printer, config: &TomlConfig) -> Result<()> {
match self {
Self::Write(cmd) => cmd.execute(printer, config).await,
Self::Reply(cmd) => cmd.execute(printer, config).await,
Self::Forward(cmd) => cmd.execute(printer, config).await,
Self::Save(cmd) => cmd.execute(printer, config).await,
Self::Send(cmd) => cmd.execute(printer, config).await,
}
}
}