use clap::{Parser, Subcommand};
use std::path::PathBuf;
use steer_core::api::Model;
use strum::IntoEnumIterator;
#[derive(Debug, Clone, Copy)]
pub struct ModelArg(pub Model);
impl From<ModelArg> for Model {
fn from(arg: ModelArg) -> Self {
arg.0
}
}
impl clap::ValueEnum for ModelArg {
fn value_variants<'a>() -> &'a [Self] {
use once_cell::sync::Lazy;
static VARIANTS: Lazy<Vec<ModelArg>> = Lazy::new(|| Model::iter().map(ModelArg).collect());
&VARIANTS
}
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
let s: &'static str = self.0.into();
let mut pv = clap::builder::PossibleValue::new(s);
for alias in self.0.aliases() {
pv = pv.alias(alias);
}
Some(pv)
}
}
#[derive(Parser)]
#[command(version, about, long_about = None, author)]
pub struct Cli {
#[arg(long)]
pub session: Option<String>,
#[arg(short, long)]
pub directory: Option<std::path::PathBuf>,
#[arg(short, long, value_enum, default_value_t = ModelArg(Model::default()))]
pub model: ModelArg,
#[arg(long)]
pub remote: Option<String>,
#[arg(long)]
pub system_prompt: Option<String>,
#[arg(long, env = "CONDUCTOR_SESSION_DB", hide = true)]
pub session_db: Option<PathBuf>,
#[arg(long)]
pub session_config: Option<PathBuf>,
#[arg(long)]
pub theme: Option<String>,
#[arg(long, hide = true)]
pub force_setup: bool,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand, Clone)]
pub enum Commands {
Tui {
#[arg(long)]
remote: Option<String>,
#[arg(long)]
session_config: Option<PathBuf>,
#[arg(long)]
theme: Option<String>,
#[arg(long, hide = true)]
force_setup: bool,
},
Preferences {
#[command(subcommand)]
action: PreferencesCommands,
},
Headless {
#[arg(long)]
model: Option<ModelArg>,
#[arg(long)]
messages_json: Option<PathBuf>,
#[arg(long)]
session: Option<String>,
#[arg(long)]
session_config: Option<PathBuf>,
#[arg(long)]
system_prompt: Option<String>,
#[arg(long)]
remote: Option<String>,
},
Server {
#[arg(long, default_value = "50051")]
port: u16,
#[arg(long, default_value = "127.0.0.1")]
bind: String,
},
Session {
#[command(subcommand)]
session_command: SessionCommands,
},
#[clap(hide = true)]
Notify {
#[clap(long)]
title: String,
#[clap(long)]
message: String,
#[clap(long)]
sound: Option<String>,
},
}
#[derive(Subcommand, Clone)]
pub enum PreferencesCommands {
Show,
Edit,
Reset,
}
#[derive(Subcommand, Clone)]
pub enum SessionCommands {
List {
#[arg(long)]
active: bool,
#[arg(long, default_value = "20")]
limit: u32,
},
Create {
#[arg(long)]
session_config: Option<PathBuf>,
#[arg(long)]
metadata: Option<String>,
#[arg(long)]
system_prompt: Option<String>,
},
Delete {
session_id: String,
#[arg(long)]
force: bool,
},
Show {
session_id: String,
},
}