Skip to main content

hh_cli/cli/
commands.rs

1use clap::{Parser, Subcommand};
2
3#[derive(Debug, Parser)]
4#[command(name = "hh", about = "Happy Harness", version)]
5pub struct Cli {
6    #[command(subcommand)]
7    pub command: Option<Commands>,
8}
9
10#[derive(Debug, Subcommand)]
11pub enum Commands {
12    /// Start interactive chat session
13    Chat {
14        /// Limit autonomous turns; unlimited when omitted
15        #[arg(long, value_parser = parse_positive_usize)]
16        max_turns: Option<usize>,
17        /// Select agent to use
18        #[arg(long)]
19        agent: Option<String>,
20    },
21
22    /// Run one prompt and exit
23    Run {
24        prompt: String,
25        /// Limit autonomous turns; unlimited when omitted
26        #[arg(long, value_parser = parse_positive_usize)]
27        max_turns: Option<usize>,
28        /// Select agent to use
29        #[arg(long)]
30        agent: Option<String>,
31    },
32    /// List available agents
33    Agents,
34    /// List available tools
35    Tools,
36    /// Manage configuration
37    Config {
38        #[command(subcommand)]
39        command: ConfigCommand,
40    },
41}
42
43#[derive(Debug, Subcommand)]
44pub enum ConfigCommand {
45    Init,
46    Show,
47}
48
49fn parse_positive_usize(raw: &str) -> Result<usize, String> {
50    let value = raw
51        .parse::<usize>()
52        .map_err(|_| format!("invalid integer: {raw}"))?;
53    if value == 0 {
54        return Err("value must be greater than 0".to_string());
55    }
56    Ok(value)
57}