mod create;
mod delete;
mod list;
mod read;
mod update;
use anyhow::Result;
use clap::Subcommand;
use pimalaya_toolbox::terminal::printer::Printer;
use crate::account::Account;
use self::{
create::CreateItemCommand, delete::DeleteItemCommand, list::ListItemsCommand,
read::ReadItemCommand, update::UpdateItemCommand,
};
#[derive(Debug, Subcommand)]
pub enum ItemSubcommand {
#[command(alias = "new", alias = "add")]
Create(CreateItemCommand),
#[command(alias = "get")]
Read(ReadItemCommand),
#[command(alias = "lst")]
List(ListItemsCommand),
#[command(alias = "set", alias = "change")]
Update(UpdateItemCommand),
#[command(alias = "remove", alias = "rm")]
Delete(DeleteItemCommand),
}
impl ItemSubcommand {
pub fn execute(self, printer: &mut impl Printer, account: Account) -> Result<()> {
match self {
Self::Create(cmd) => cmd.execute(printer, account),
Self::Read(cmd) => cmd.execute(printer, account),
Self::List(cmd) => cmd.execute(printer, account),
Self::Update(cmd) => cmd.execute(printer, account),
Self::Delete(cmd) => cmd.execute(printer, account),
}
}
}