use clap::{Args, Parser, Subcommand, ValueEnum};
#[derive(Parser, Debug)]
#[command(
name = "looop",
version,
disable_help_subcommand = true,
// A bare `looop` is not a command: main prints the manual. We surface our own
// manual rather than clap's auto help for the no-subcommand case.
arg_required_else_help = false
)]
pub struct Cli {
#[command(subcommand)]
pub cmd: Option<Cmd>,
}
#[derive(Subcommand, Debug)]
pub enum Cmd {
Help,
Version,
Up(UpArgs),
Down,
Watch(WatchArgs),
Cost,
Config(ConfigArgs),
#[command(name = "_")]
Underscore {
#[command(subcommand)]
verb: Verb,
},
}
#[derive(Args, Debug)]
pub struct UpArgs {
#[arg(long)]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WatchArgs {
pub id: Option<String>,
#[arg(long, short = 'a')]
pub all: bool,
#[arg(long, short = 's')]
pub since: Option<String>,
}
#[derive(Args, Debug)]
pub struct ConfigArgs {
#[arg(value_enum)]
pub shell: Shell,
}
#[derive(Copy, Clone, Debug, ValueEnum)]
pub enum Shell {
Zsh,
Bash,
}
#[derive(Subcommand, Debug)]
pub enum Verb {
Pulse,
State(StateArgs),
Wait(WaitArgs),
Asks(AsksArgs),
Answer(AnswerArgs),
Goal(GoalArgs),
Sensor(SensorArgs),
Playbook(PlaybookArgs),
Run(RunArgs),
Worker(WorkerArgs),
Ask(AskArgs),
Kill(KillArgs),
Send(SendArgs),
Screenshot(ScreenshotArgs),
Claim(ClaimArgs),
Unclaim(ClaimArgs),
Cost(CostRecordArgs),
}
#[derive(Args, Debug, Default)]
pub struct JournalOpt {
#[arg(long)]
pub journal: Option<String>,
}
#[derive(Args, Debug)]
pub struct StateArgs {
#[arg(long)]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct WaitArgs {
#[arg(long)]
pub json: bool,
#[arg(long)]
pub actionable: bool,
#[arg(long)]
pub only_asks: bool,
}
#[derive(Args, Debug)]
pub struct AsksArgs {
#[arg(long)]
pub json: bool,
}
#[derive(Args, Debug)]
pub struct AnswerArgs {
pub ask_id: String,
pub body: Vec<String>,
#[arg(long)]
pub force: bool,
}
#[derive(Args, Debug)]
pub struct GoalArgs {
#[command(subcommand)]
pub op: GoalOp,
}
#[derive(Subcommand, Debug)]
pub enum GoalOp {
Write {
id: String,
body: Vec<String>,
#[command(flatten)]
journal: JournalOpt,
},
Archive {
id: String,
#[command(flatten)]
journal: JournalOpt,
},
}
#[derive(Args, Debug)]
pub struct SensorArgs {
#[command(subcommand)]
pub op: SensorOp,
}
#[derive(Subcommand, Debug)]
pub enum SensorOp {
Write {
name: String,
script: Vec<String>,
#[command(flatten)]
journal: JournalOpt,
},
}
#[derive(Args, Debug)]
pub struct PlaybookArgs {
#[command(subcommand)]
pub op: PlaybookOp,
}
#[derive(Subcommand, Debug)]
pub enum PlaybookOp {
Write {
body: Vec<String>,
#[command(flatten)]
journal: JournalOpt,
},
}
#[derive(Args, Debug)]
pub struct RunArgs {
#[arg(long)]
pub reason: Option<String>,
#[command(flatten)]
pub journal: JournalOpt,
#[arg(trailing_var_arg = true, allow_hyphen_values = true)]
pub cmd: Vec<String>,
}
#[derive(Args, Debug)]
pub struct WorkerArgs {
#[command(subcommand)]
pub op: WorkerOp,
}
#[derive(Subcommand, Debug)]
pub enum WorkerOp {
Start {
id: String,
prompt: Vec<String>,
#[command(flatten)]
journal: JournalOpt,
},
Kill { id: String },
}
#[derive(Args, Debug)]
pub struct AskArgs {
pub worker: Option<String>,
#[arg(long)]
pub prompt: String,
#[arg(long = "ref")]
pub reference: Option<String>,
#[arg(long, value_delimiter = ',')]
pub options: Vec<String>,
}
#[derive(Args, Debug)]
pub struct KillArgs {
pub id: String,
}
#[derive(Args, Debug)]
pub struct SendArgs {
pub id: String,
pub text: Vec<String>,
#[arg(long = "no-newline", short = 'n')]
pub no_newline: bool,
}
#[derive(Args, Debug)]
pub struct ScreenshotArgs {
pub id: Option<String>,
#[arg(long)]
pub ansi: bool,
#[arg(long)]
pub json: bool,
#[arg(long)]
pub plain: bool,
#[arg(long = "no-trim")]
pub no_trim: bool,
}
#[derive(Args, Debug)]
pub struct ClaimArgs {
pub name: String,
#[arg(long)]
pub session: Option<String>,
}
#[derive(Args, Debug)]
pub struct CostRecordArgs {
#[command(subcommand)]
pub op: CostRecordOp,
}
#[derive(Subcommand, Debug)]
pub enum CostRecordOp {
Session {
id: String,
runner: String,
usd: String,
},
}