1use std::path::PathBuf;
2
3use clap::{Parser, Subcommand};
4
5#[derive(Debug, Parser)]
6#[command(name = "hh", about = "Happy Harness", version)]
7pub struct Cli {
8 #[command(subcommand)]
9 pub command: Commands,
10}
11
12#[derive(Debug, Subcommand)]
13pub enum Commands {
14 Chat {
16 #[arg(long)]
18 debug: Option<PathBuf>,
19 #[arg(long, value_parser = parse_positive_usize)]
21 max_turns: Option<usize>,
22 #[arg(long)]
24 agent: Option<String>,
25 },
26 Replay {
28 dir: PathBuf,
30 #[arg(short, long, default_value = "100")]
32 delay: u64,
33 #[arg(short, long)]
35 loop_replay: bool,
36 },
37 Run {
39 prompt: String,
40 #[arg(long)]
42 debug: Option<PathBuf>,
43 #[arg(long, value_parser = parse_positive_usize)]
45 max_turns: Option<usize>,
46 #[arg(long)]
48 agent: Option<String>,
49 },
50 Agents,
52 Tools,
54 Config {
56 #[command(subcommand)]
57 command: ConfigCommand,
58 },
59}
60
61#[derive(Debug, Subcommand)]
62pub enum ConfigCommand {
63 Init,
64 Show,
65}
66
67fn parse_positive_usize(raw: &str) -> Result<usize, String> {
68 let value = raw
69 .parse::<usize>()
70 .map_err(|_| format!("invalid integer: {raw}"))?;
71 if value == 0 {
72 return Err("value must be greater than 0".to_string());
73 }
74 Ok(value)
75}