mirror of
https://github.com/pimalaya/himalaya.git
synced 2026-06-17 21:37:55 +08:00
47 lines
1.7 KiB
Rust
47 lines
1.7 KiB
Rust
use anyhow::Result;
|
|
use clap::Subcommand;
|
|
use pimalaya_cli::printer::Printer;
|
|
|
|
use crate::maildir::{
|
|
client::MaildirClient, create::MaildirMailboxCreateCommand,
|
|
delete::MaildirMailboxDeleteCommand, envelope::command::MaildirEnvelopeCommand,
|
|
flag::command::MaildirFlagCommand, list::MaildirMailboxListCommand,
|
|
message::command::MaildirMessageCommand, rename::MaildirMailboxRenameCommand,
|
|
};
|
|
|
|
/// MAILDIR CLI (requires the `maildir` cargo feature).
|
|
///
|
|
/// This command gives you access to the MAILDIR CLI API, and allows you
|
|
/// to manage MAILDIR mailboxes, envelopes, flags, messages etc.
|
|
#[derive(Debug, Subcommand)]
|
|
#[command(rename_all = "kebab-case")]
|
|
pub enum MaildirCommand {
|
|
Create(MaildirMailboxCreateCommand),
|
|
Rename(MaildirMailboxRenameCommand),
|
|
Delete(MaildirMailboxDeleteCommand),
|
|
List(MaildirMailboxListCommand),
|
|
|
|
#[command(subcommand)]
|
|
#[command(aliases = ["msgs", "msg"])]
|
|
Messages(MaildirMessageCommand),
|
|
#[command(subcommand)]
|
|
Flags(MaildirFlagCommand),
|
|
#[command(subcommand)]
|
|
Envelopes(MaildirEnvelopeCommand),
|
|
}
|
|
|
|
impl MaildirCommand {
|
|
pub fn execute(self, printer: &mut impl Printer, account: MaildirAccount) -> Result<()> {
|
|
match self {
|
|
Self::Create(cmd) => cmd.execute(printer, account),
|
|
Self::Rename(cmd) => cmd.execute(printer, account),
|
|
Self::Delete(cmd) => cmd.execute(printer, account),
|
|
Self::List(cmd) => cmd.execute(printer, account),
|
|
|
|
Self::Messages(cmd) => cmd.execute(printer, account),
|
|
Self::Flags(cmd) => cmd.execute(printer, account),
|
|
Self::Envelopes(cmd) => cmd.execute(printer, account),
|
|
}
|
|
}
|
|
}
|