use anyhow::Result;
use clap::Subcommand;
use pimalaya_cli::printer::Printer;
use crate::{
account::context::Account,
mbox::{
client::MboxClient, create::MboxMailboxCreateCommand, delete::MboxMailboxDeleteCommand,
flag::cli::MboxFlagCommand, list::MboxMailboxListCommand, message::cli::MboxMessageCommand,
rename::MboxMailboxRenameCommand,
},
};
#[derive(Debug, Subcommand)]
#[command(rename_all = "kebab-case")]
pub enum MboxCommand {
Create(MboxMailboxCreateCommand),
Rename(MboxMailboxRenameCommand),
Delete(MboxMailboxDeleteCommand),
List(MboxMailboxListCommand),
#[command(subcommand)]
#[command(visible_alias = "msg", aliases = ["messages", "msgs"])]
Message(MboxMessageCommand),
#[command(subcommand)]
#[command(alias = "flags")]
Flag(MboxFlagCommand),
}
impl MboxCommand {
pub fn execute(
self,
printer: &mut impl Printer,
account: &mut Account,
client: &mut MboxClient,
) -> Result<()> {
match self {
Self::Create(cmd) => cmd.execute(printer, client),
Self::Rename(cmd) => cmd.execute(printer, client),
Self::Delete(cmd) => cmd.execute(printer, client),
Self::List(cmd) => cmd.execute(printer, account, client),
Self::Message(cmd) => cmd.execute(printer, client),
Self::Flag(cmd) => cmd.execute(printer, account, client),
}
}
}