use anyhow::{ Context, Result, }; use clap::{ Parser, Subcommand, }; use etecal::session::{ store_etebase_session, restore_etebase_session, }; #[derive(Subcommand, Clone)] #[command(arg_required_else_help = true)] enum Commands { /// Login with user account Login { #[arg(long)] url: String, user: String, pass: String, }, /// Display available calendars Calendars, } #[derive(Parser)] #[command(version, about, long_about = None, arg_required_else_help = true)] struct Cli { #[command(subcommand)] command: Option, /// Path to config directory #[arg(long)] config: Option, } fn main() -> Result<()> { let cli = Cli::parse(); let command = &cli.command.context("No command provided")?.clone(); match &command { Commands::Login{url, user, pass} => { store_etebase_session(url, user, pass)?; }, Commands::Calendars => { let etebase = restore_etebase_session()?; let collection_manager = etebase.collection_manager()?; for collection in collection_manager.list("etebase.vevent", None)?.data() { println!("{} [{}]", collection.meta()?.name().unwrap(), collection.uid()); } }, } Ok(()) }