diff --git a/src/main.rs b/src/main.rs index 1767761..36033d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,6 +11,21 @@ use etecal::session::{ restore_etebase_session, }; +#[derive(Subcommand, Clone)] +#[command(arg_required_else_help = true)] +enum CalendarCommands { + Name, + SetName { + name: String, + }, +} + +impl Default for CalendarCommands { + fn default() -> Self { + return Self::Name; + } +} + #[derive(Subcommand, Clone)] #[command(arg_required_else_help = true)] enum Commands { @@ -23,6 +38,13 @@ enum Commands { }, /// Display available calendars Calendars, + /// Display calendar property + Calendar { + /// Calendar uid + uid: String, + #[command(subcommand)] + command: Option, + }, } #[derive(Parser)] @@ -52,6 +74,27 @@ fn main() -> Result<()> { println!("{} [{}]", collection.meta()?.name().unwrap(), collection.uid()); } }, + Commands::Calendar{uid, command} => { + let etebase = restore_etebase_session()?; + let collection_manager = etebase.collection_manager()?; + + let mut collection = collection_manager.fetch(uid, None)?; + let mut meta = collection.meta()?; + + match &command.clone().unwrap_or_default() { + CalendarCommands::Name => { + println!("{} [{}]", meta.name().unwrap(), collection.uid()); + }, + CalendarCommands::SetName{name} => { + meta.set_name(Some(name)); + + collection.set_meta(&meta)?; + + collection_manager.upload(&collection, None)?; + + }, + } + }, } Ok(())