Skip to main content

ralph/cli/
runner.rs

1//! CLI arguments for runner management commands.
2//!
3//! Responsibilities:
4//! - Define RunnerArgs and RunnerCommand enums for Clap.
5//! - Delegate command execution to commands/runner/ module.
6//!
7//! Not handled here:
8//! - Capability data retrieval (see commands/runner/capabilities.rs).
9//! - Binary detection logic (see commands/runner/detection.rs).
10
11use anyhow::Result;
12use clap::{Args, Subcommand, ValueEnum};
13
14/// Arguments for the `ralph runner` command.
15#[derive(Args)]
16pub struct RunnerArgs {
17    #[command(subcommand)]
18    pub command: RunnerCommand,
19}
20
21#[derive(Subcommand)]
22pub enum RunnerCommand {
23    /// Show capabilities for a specific runner (models, features, binary status).
24    Capabilities(CapabilitiesArgs),
25    /// List all available runners with brief descriptions.
26    List(ListArgs),
27}
28
29/// Output format for runner commands.
30#[derive(Debug, Clone, Copy, Default, ValueEnum)]
31pub enum RunnerFormat {
32    /// Human-readable text output (default).
33    #[default]
34    Text,
35    /// Machine-readable JSON output for scripting/CI.
36    Json,
37}
38
39#[derive(Args)]
40pub struct CapabilitiesArgs {
41    /// Runner to inspect (codex, opencode, gemini, claude, cursor, kimi, pi, or plugin id).
42    pub runner: String,
43
44    /// Output format (text or json).
45    #[arg(long, value_enum, default_value = "text")]
46    pub format: RunnerFormat,
47}
48
49#[derive(Args)]
50pub struct ListArgs {
51    /// Output format (text or json).
52    #[arg(long, value_enum, default_value = "text")]
53    pub format: RunnerFormat,
54}
55
56pub fn handle_runner_capabilities(args: CapabilitiesArgs) -> Result<()> {
57    crate::commands::runner::capabilities::handle_capabilities(&args.runner, args.format)
58}
59
60pub fn handle_runner_list(args: ListArgs) -> Result<()> {
61    crate::commands::runner::list::handle_list(args.format)
62}