Designing the configuration UI in full made the case against building it. Its audience would be people who find TOML hard, but with bring-your-own OAuth client settled, every user must first create a Google Cloud project, configure a consent screen and put a secret in a keyring — a far higher bar than editing thirty lines of config. Anyone who clears it can edit the file; anyone who cannot never reaches the file. Against that stood three dependencies, five modules, an auth.rs refactor and a security surface guarding something that reads the config and touches the keyring. `doctor` and `status` had already absorbed most of what it was for. The reasoning is recorded in TODO.md and SPECS.md rather than left as an apparent oversight. The run lock is not a UI feature and closes a gap that already existed: nothing stopped a timer firing into a hand-run cycle, and two cycles interleaving writes over the same vdirs is what the design otherwise avoids. flock is used rather than a pid file because the kernel releases it however the process ends, so a crash cannot leave a lock to clear by hand — which also means a lock we failed to take is held by a live process, so the pid in it is worth reporting. The one idea worth keeping from the UI design was collection discovery, which needed no web layer. `calcalist discover` prints a ready-to-paste endpoint block per calendar a server offers, removing the most error-prone field in the config. pimsync's discovery output is undocumented, so the format was established against a real server first. Two things it teaches: everything arrives on stdout including failures, and a pair has two storages, so pimsync reports the scratch vdir's contents too — parsing anchors on the heading naming the server, or a probe directory's leftovers would be offered as the user's calendars. Verified against Posteo as well as Radicale: all four calendars found, the first matching the URL already configured. Also fixes a real defect in the test harness rather than its symptom. Ports were chosen by binding one and letting go, so two tests could pick the same number — and the loser's readiness check then succeeded against the winner's server, silently sharing it. Startup now confirms the child we spawned is the one alive, retries on another port if not, and waits for a real HTTP response rather than an open socket. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
92 lines
2.6 KiB
Rust
92 lines
2.6 KiB
Rust
//! 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<PathBuf>,
|
|
|
|
#[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<String>,
|
|
},
|
|
/// 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,
|
|
},
|
|
}
|