use crate::exec::ExecCommand;
use clap::{command, Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(version, about, long_about = None)]
pub struct CliArgs {
#[command(subcommand)]
pub cmd: CliCommand,
}
#[derive(Subcommand, Debug)]
pub enum CliCommand {
Init(InitArgs),
#[command(name = "init-base", about = "Init the ~/.devai-base")]
InitBase,
Run(RunArgs),
New(NewArgs),
List,
}
impl CliCommand {
pub fn is_interactive(&self) -> bool {
match self {
CliCommand::Run(run_args) => !run_args.not_interactive,
CliCommand::Init(_) => false,
CliCommand::InitBase => false,
CliCommand::New(_) => false,
CliCommand::List => false,
}
}
}
#[derive(Parser, Debug)]
pub struct RunArgs {
pub cmd_agent_name: String,
#[arg(short = 'i', long = "input")]
pub on_inputs: Option<Vec<String>>,
#[arg(short = 'f', long = "on-files")]
pub on_files: Option<Vec<String>>,
#[arg(short = 'w', long = "watch")]
pub watch: bool,
#[arg(short = 'v', long = "verbose")]
pub verbose: bool,
#[arg(short = 'o', long = "open")]
pub open: bool,
#[arg(long = "dry", value_parser = ["req", "res"])]
pub dry_mode: Option<String>,
#[arg(long = "not-interactive", alias = "ni")]
pub not_interactive: bool,
}
#[derive(Parser, Debug)]
pub struct NewArgs {
pub agent_path: String,
#[arg(short = 'o', long = "open")]
pub open: bool,
}
#[derive(Parser, Debug)]
pub struct InitArgs {
pub path: Option<String>,
}
impl From<CliCommand> for ExecCommand {
fn from(cli_cmd: CliCommand) -> Self {
match cli_cmd {
CliCommand::Init(init_args) => ExecCommand::Init(init_args),
CliCommand::InitBase => ExecCommand::InitBase,
CliCommand::Run(run_args) => ExecCommand::RunCommandAgent(run_args),
CliCommand::New(new_args) => ExecCommand::NewCommandAgent(new_args),
CliCommand::List => ExecCommand::List,
}
}
}