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 Chat {
14 #[arg(long, value_parser = parse_positive_usize)]
16 max_turns: Option<usize>,
17 #[arg(long)]
19 agent: Option<String>,
20 },
21
22 Run {
24 prompt: String,
25 #[arg(long, value_parser = parse_positive_usize)]
27 max_turns: Option<usize>,
28 #[arg(long)]
30 agent: Option<String>,
31 },
32 Agents,
34 Tools,
36 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}