use super::{Error, Fx, Outcome};
use crate::prompt::dispatch_cli;
use std::path::PathBuf;
#[derive(clap::Args, Debug)]
pub struct Args {
pub role: String,
pub repo: PathBuf,
pub branch: String,
#[arg(long)]
pub goal: Option<String>,
#[arg(long)]
pub from: Option<String>,
#[arg(long)]
pub name: Option<String>,
#[arg(long = "pin", value_name = "DEST=SRC")]
pub pin: Vec<String>,
}
pub fn run(args: Args, fx: &mut Fx) -> Result<Outcome, Error> {
crate::name::require_agent_id(&args.branch)
.map_err(|e| Error::new(format!("dispatch {}", args.role), e))?;
let pins = crate::prompt::pinned_doc::load(&args.pin)
.map_err(|e| Error::new(format!("dispatch {}", args.role), e))?;
dispatch_cli::run(
&args.role,
&args.repo,
&args.branch,
args.goal.as_deref(),
args.from.as_deref(),
args.name.as_deref(),
&pins,
&fx.driver_target,
)
.map_err(|e| Error::new(format!("dispatch {}", args.role), e))?;
Ok(Outcome::Quiet)
}