//! Command line surface. use std::path::PathBuf; use clap::{Parser, Subcommand}; #[derive(Debug, Parser)] #[command( name = "calcalist", version, about = "Aggregate and sync events between CalDAV, Google Calendar and iCal feeds" )] pub struct Cli { /// Configuration file (default: $XDG_CONFIG_HOME/calcalist/calcalist.toml) #[arg(long, short, global = true, value_name = "FILE")] pub config: Option, #[command(subcommand)] pub command: Command, } #[derive(Debug, Subcommand)] pub enum Command { /// Run one synchronisation cycle Sync { /// Report what would change without writing anything #[arg(long)] dry_run: bool, /// Proceed even when the mass-deletion guard trips #[arg(long)] force: bool, }, /// Show endpoints, aggregates and the last sync result Status, /// List the calendars a CalDAV server offers, as endpoint blocks to paste Discover { /// The account or principal URL to enumerate, not a single calendar url: String, /// Username to authenticate as #[arg(long)] username: String, /// Command printing the password, exactly as it would appear in the /// configuration. Secrets are never passed as arguments. #[arg(long, value_name = "COMMAND")] secret_command: Option, }, /// Google account operations Google { #[command(subcommand)] command: GoogleCommand, }, /// Aggregate maintenance Aggregate { #[command(subcommand)] command: AggregateCommand, }, /// Remove local mirrors of endpoints the configuration no longer names Prune { /// Delete them; without this the command only reports what it found #[arg(long)] force: bool, }, /// Check that the environment and configuration are usable Doctor, } #[derive(Debug, Subcommand)] pub enum GoogleCommand { /// Authorise calcalist against a Google account Login { /// Endpoint id to authorise endpoint: String, }, } #[derive(Debug, Subcommand)] pub enum AggregateCommand { /// Move an aggregate to a different target endpoint Retarget { /// Aggregate id id: String, /// Endpoint id to publish the aggregate to from now on #[arg(long = "to", value_name = "ENDPOINT")] to: String, /// Leave mirrored events on the previous target (default) #[arg(long, conflicts_with = "purge_old")] keep_old: bool, /// Delete calcalist's mirrored events from the previous target #[arg(long)] purge_old: bool, }, }