cellstate/entity/
models.rs1use anyhow::Result;
6use clap::{ArgMatches, Command};
7
8use super::client::ApiClient;
9use super::output::OutputConfig;
10
11const BASE: &str = "/api/v1/models";
12
13pub fn build_command() -> Command {
14 Command::new("models")
15 .about("Query available models and providers")
16 .subcommand_required(true)
17 .subcommand(Command::new("list").about("List available models"))
18 .subcommand(Command::new("providers").about("List model providers"))
19}
20
21pub async fn dispatch(
22 matches: &ArgMatches,
23 client: &ApiClient,
24 output: &OutputConfig,
25 _session: &crate::session::CliSession,
26) -> Result<()> {
27 match matches.subcommand() {
28 Some(("list", _sub)) => {
29 let resp: serde_json::Value = client.get_raw(BASE).await?;
30 output.print_value(&resp);
31 }
32 Some(("providers", _sub)) => {
33 let resp: serde_json::Value = client.get_raw(&format!("{BASE}/providers")).await?;
34 output.print_value(&resp);
35 }
36 _ => unreachable!("subcommand_required(true) prevents this"),
37 }
38 Ok(())
39}