use anyhow::Result;
use clap::Parser;
use io_calendar::calendar::Calendar;
use pimalaya_toolbox::terminal::printer::{Message, Printer};
use crate::{account::Account, client::Client};
#[derive(Debug, Parser)]
pub struct CreateCalendarCommand {
pub name: Option<String>,
#[arg(long, short, alias = "desc")]
pub description: Option<String>,
#[arg(long, short = 'C')]
pub color: Option<String>,
}
impl CreateCalendarCommand {
pub fn execute(self, printer: &mut impl Printer, account: Account) -> Result<()> {
let mut client = Client::new(&account)?;
let mut calendar = Calendar::new();
calendar.display_name = self.name;
calendar.description = self.description;
calendar.color = self.color;
client.create_calendar(calendar)?;
printer.out(Message::new("calendar successfully created"))
}
}