use anyhow::Result;
use clap::{Parser, Subcommand};
pub mod abort;
pub mod init;
pub mod interview;
pub mod plan;
pub mod resume;
pub mod run;
pub mod status;
#[derive(Debug, Parser)]
#[command(
name = "pitboss",
version,
about = "Orchestrate coding agents through a phased plan"
)]
pub struct Cli {
#[arg(short = 'v', long = "verbose", action = clap::ArgAction::Count, global = true)]
pub verbose: u8,
#[command(subcommand)]
pub command: Command,
}
impl Cli {
pub fn verbose_filter(&self) -> Option<&'static str> {
match self.verbose {
0 => None,
1 => Some("debug"),
_ => Some("trace"),
}
}
}
#[derive(Debug, Subcommand)]
pub enum Command {
Init,
Plan {
goal: String,
#[arg(long)]
force: bool,
#[arg(long)]
interview: bool,
},
Run {
#[arg(long)]
tui: bool,
#[arg(long)]
pr: bool,
#[arg(long = "dry-run")]
dry_run: bool,
},
Status,
Resume {
#[arg(long)]
tui: bool,
#[arg(long)]
pr: bool,
#[arg(long = "dry-run")]
dry_run: bool,
},
Abort {
#[arg(long)]
checkout_original: bool,
},
}
pub async fn dispatch(cli: Cli) -> Result<()> {
match cli.command {
Command::Init => init::run(std::env::current_dir()?),
Command::Plan {
goal,
force,
interview,
} => plan::run(std::env::current_dir()?, goal, force, interview).await,
Command::Run { tui, pr, dry_run } => {
run::run(std::env::current_dir()?, tui, pr, dry_run).await
}
Command::Status => status::run(std::env::current_dir()?),
Command::Resume { tui, pr, dry_run } => {
resume::run(std::env::current_dir()?, tui, pr, dry_run).await
}
Command::Abort { checkout_original } => {
abort::run(std::env::current_dir()?, checkout_original).await
}
}
}