Manipulate calendar names
This commit is contained in:
parent
e07eef82db
commit
b6f10a3b14
43
src/main.rs
43
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<CalendarCommands>,
|
||||
},
|
||||
}
|
||||
|
||||
#[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(())
|
||||
|
Loading…
Reference in New Issue
Block a user