//! The `spectra` command line (spec ยง19). Output follows `oxy`: colour and //! glyphs on a UTF-8 terminal, plain when piped, with `--plain` or with //! `NO_COLOR`; `--json` prints one document on stdout and nothing else. pub mod format; pub mod json; pub mod ui; use anyhow::Result; use clap::{Parser, Subcommand}; #[derive(Parser)] #[command(name = "spectra", version = env!("SPECTRA_VERSION_LONG"), about = "A control plane for AI coding agents")] pub struct Cli { /// Plain output: no colour or glyphs (also NO_COLOR, or when not a terminal) #[arg(long, global = true)] pub plain: bool, #[command(subcommand)] pub command: Command, } #[derive(Subcommand)] pub enum Command { /// The version and build of this binary Version { /// Machine-readable output #[arg(long)] json: bool, }, } pub fn run() -> Result { let cli = Cli::parse(); ui::init(cli.plain); match cli.command { Command::Version { json } => version(json), } } fn version(as_json: bool) -> Result { if as_json { println!( "{}", serde_json::json!({ "version": env!("CARGO_PKG_VERSION"), "build": env!("SPECTRA_BUILD_ID"), "mcp_protocol_versions": spectra_mcp::PROTOCOL_VERSIONS, "ledger_format": spectra_core::LEDGER_FORMAT, }) ); } else { println!("spectra {}", env!("SPECTRA_VERSION_LONG")); } Ok(0) }