use anyhow::Result;
use clap::Subcommand;
use pimalaya_cli::printer::Printer;
use crate::{
account::context::Account,
sieve::{
activate::SieveScriptActivateCommand, capability::SieveCapabilityListCommand,
check::SieveScriptCheckCommand, client::SieveClient,
deactivate::SieveScriptDeactivateCommand, delete::SieveScriptDeleteCommand,
get::SieveScriptGetCommand, list::SieveScriptListCommand, put::SieveScriptPutCommand,
raw::SieveRawCommand, rename::SieveScriptRenameCommand,
},
};
#[derive(Debug, Subcommand)]
#[command(rename_all = "kebab-case")]
pub enum SieveCommand {
#[command(alias = "capabilities")]
Capability(SieveCapabilityListCommand),
List(SieveScriptListCommand),
Get(SieveScriptGetCommand),
Put(SieveScriptPutCommand),
Check(SieveScriptCheckCommand),
Rename(SieveScriptRenameCommand),
Delete(SieveScriptDeleteCommand),
Activate(SieveScriptActivateCommand),
Deactivate(SieveScriptDeactivateCommand),
Raw(SieveRawCommand),
}
impl SieveCommand {
pub fn execute(
self,
printer: &mut impl Printer,
account: &mut Account,
client: &mut SieveClient,
) -> Result<()> {
match self {
Self::Capability(cmd) => cmd.execute(printer, account, client),
Self::List(cmd) => cmd.execute(printer, account, client),
Self::Get(cmd) => cmd.execute(printer, client),
Self::Put(cmd) => cmd.execute(printer, client),
Self::Check(cmd) => cmd.execute(printer, client),
Self::Rename(cmd) => cmd.execute(printer, client),
Self::Delete(cmd) => cmd.execute(printer, client),
Self::Activate(cmd) => cmd.execute(printer, client),
Self::Deactivate(cmd) => cmd.execute(printer, client),
Self::Raw(cmd) => cmd.execute(printer, client),
}
}
}