use std::path::PathBuf; use clap::{Parser, Subcommand, ValueEnum}; use crate::help; #[derive(Debug, Parser)] #[command( name = "sope", about = "Deploy an observability stack (hub / satellites)", long_about = "Build Nix dockerTools images, generate Compose stacks, and deploy over SSH.\n\ Hub (Grafana/Loki/Tempo/Prometheus) + satellites (Alloy/cAdvisor) with Bearer push.\n\ Config: sope.toml — one [hub] and as many [[satellites]] as you need.", styles = help::clap_styles(), disable_help_subcommand = true )] pub struct Cli { /// Path to sope.toml #[arg(short, long, default_value = "sope.toml", global = true)] pub config: PathBuf, #[command(subcommand)] pub command: Command, } #[derive(Debug, Subcommand)] pub enum Command { /// Build Nix dockerTools images and load them into Docker Build { /// Target Linux arch: amd64 or arm64 (default: this machine) #[arg(long, value_name = "ARCH")] arch: Option, }, /// Generate Compose/config artefacts without deploying Render { /// Output directory (default: .sope) #[arg(short, long)] out: Option, }, /// Show what deploy would change (configs / images) without applying Plan { /// Target: all (hub+satellites), hub, or satellite #[arg(value_enum, default_value_t = DeployTarget::All)] target: DeployTarget, /// Satellite name (= name field of a [[satellites]] block) #[arg(long)] name: Option, /// Re-read remotes into sope.state.json before planning #[arg(long)] refresh: bool, }, /// Deploy over SSH — only applies needed changes (see sope plan) Deploy { /// Target: all (hub+satellites), hub, or satellite #[arg(value_enum, default_value_t = DeployTarget::All)] target: DeployTarget, /// Satellite name (= name field of a [[satellites]] block) #[arg(long)] name: Option, /// Do not rebuild images (error if the plan needs new images) #[arg(long)] skip_build: bool, /// Force full atomic redeploy even when only configs changed #[arg(long)] full: bool, /// Re-read remotes into sope.state.json before planning #[arg(long)] refresh: bool, }, /// Show docker compose ps on the nodes Status { /// Target: all, hub, or satellite #[arg(value_enum, default_value_t = DeployTarget::All)] target: DeployTarget, /// Satellite name (= name field of a [[satellites]] block) #[arg(long)] name: Option, }, /// Local web UI for status, deploy, and destroy Ui { /// Listen address (default: 127.0.0.1) #[arg(long, default_value = "127.0.0.1")] bind: String, /// HTTP port (default: 8743) #[arg(long, default_value_t = 8743)] port: u16, }, /// Tear down remote infra with no leftover traces Destroy { /// Target: all (satellites then hub), hub, or satellite #[arg(value_enum, default_value_t = DeployTarget::All)] target: DeployTarget, /// Satellite name (= name field of a [[satellites]] block) #[arg(long)] name: Option, /// Confirm irreversible destruction #[arg(long)] yes: bool, }, } #[derive(Debug, Clone, Copy, ValueEnum, Default)] pub enum DeployTarget { #[default] All, Hub, Satellite, }