Coverage / src/cli/mod.rs 0.0%
0 of 22 lines run, 0 of 2 functions · run #2 on main · run missed
| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | | pub mod format; |
| 6 | | pub mod json; |
| 7 | | pub mod ui; |
| 8 | |
|
| 9 | | use anyhow::Result; |
| 10 | | use clap::{Parser, Subcommand}; |
| 11 | |
|
| 12 | | #[derive(Parser)] |
| 13 | | #[command(name = "spectra", version = env!("SPECTRA_VERSION_LONG"), about = "A control plane for AI coding agents")] |
| 14 | | pub struct Cli { |
| 15 | | |
| 16 | | #[arg(long, global = true)] |
| 17 | | pub plain: bool, |
| 18 | | #[command(subcommand)] |
| 19 | | pub command: Command, |
| 20 | | } |
| 21 | |
|
| 22 | | #[derive(Subcommand)] |
| 23 | | pub enum Command { |
| 24 | | |
| 25 | | Version { |
| 26 | | |
| 27 | | #[arg(long)] |
| 28 | | json: bool, |
| 29 | | }, |
| 30 | | } |
| 31 | |
|
| 32 | 0× | pub fn run() -> Result<i32> { |
| 33 | 0× | let cli = Cli::parse(); |
| 34 | 0× | ui::init(cli.plain); |
| 35 | 0× | match cli.command { |
| 36 | 0× | Command::Version { json } => version(json), |
| 37 | | } |
| 38 | 0× | } |
| 39 | |
|
| 40 | 0× | fn version(as_json: bool) -> Result<i32> { |
| 41 | 0× | if as_json { |
| 42 | 0× | println!( |
| 43 | 0× | "{}", |
| 44 | 0× | serde_json::json!({ |
| 45 | 0× | "version": env!("CARGO_PKG_VERSION"), |
| 46 | 0× | "build": env!("SPECTRA_BUILD_ID"), |
| 47 | 0× | "mcp_protocol_versions": spectra_mcp::PROTOCOL_VERSIONS, |
| 48 | 0× | "ledger_format": spectra_core::LEDGER_FORMAT, |
| 49 | 0× | }) |
| 50 | 0× | ); |
| 51 | 0× | } else { |
| 52 | 0× | println!("spectra {}", env!("SPECTRA_VERSION_LONG")); |
| 53 | 0× | } |
| 54 | 0× | Ok(0) |
| 55 | 0× | } |