From 50ee95ba1e01a16cfaa778e1344e6769a887923c Mon Sep 17 00:00:00 2001 From: Evandro Fonseca Junior Date: Thu, 26 Mar 2026 19:00:19 -0300 Subject: [PATCH] feat: enrich cli semantic summaries --- crates/localllm-cli/src/main.rs | 93 +++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 10 deletions(-) diff --git a/crates/localllm-cli/src/main.rs b/crates/localllm-cli/src/main.rs index 1a9e5b9..4e4884c 100644 --- a/crates/localllm-cli/src/main.rs +++ b/crates/localllm-cli/src/main.rs @@ -186,21 +186,94 @@ fn main() -> anyhow::Result<()> { fn render_command_summary(cli: &Cli) -> String { format!( - "command={} server={}", + "command={} server={} format={} models_dir={}", command_summary(&cli.command), - cli.server + cli.server, + output_format_name(cli.format), + cli.models_dir ) } -fn command_summary(command: &Commands) -> &'static str { +fn command_summary(command: &Commands) -> String { match command { - Commands::Status => "status", - Commands::Models(_) => "models", - Commands::Auth(_) => "auth", - Commands::Config(_) => "config", - Commands::Bench(_) => "bench", - Commands::Logs(_) => "logs", - Commands::Doctor => "doctor", + Commands::Status => "status".to_owned(), + Commands::Models(models) => models_command_summary(models), + Commands::Auth(auth) => auth_command_summary(auth), + Commands::Config(config) => config_command_summary(config), + Commands::Bench(bench) => bench_command_summary(bench), + Commands::Logs(args) => format!("logs lines={}", args.lines), + Commands::Doctor => "doctor".to_owned(), + } +} + +fn output_format_name(format: OutputFormat) -> &'static str { + match format { + OutputFormat::Text => "text", + OutputFormat::Json => "json", + } +} + +fn models_command_summary(command: &ModelsCommand) -> String { + match &command.command { + ModelsSubcommand::List => "models.list".to_owned(), + ModelsSubcommand::Scan => "models.scan".to_owned(), + ModelsSubcommand::Load(args) => match &args.alias { + Some(alias) => format!("models.load model={} alias={}", args.model, alias), + None => format!("models.load model={}", args.model), + }, + ModelsSubcommand::Unload(args) => match &args.model { + Some(model) => format!("models.unload model={}", model), + None => "models.unload model=active".to_owned(), + }, + ModelsSubcommand::Use(args) => format!("models.use model={}", args.model), + ModelsSubcommand::Watch => "models.watch".to_owned(), + ModelsSubcommand::Download(args) => format!("models.download repo={}", args.repo), + ModelsSubcommand::Remove(args) => format!("models.remove model={}", args.model), + } +} + +fn auth_command_summary(command: &AuthCommand) -> String { + match &command.command { + AuthSubcommand::Status => "auth.status".to_owned(), + AuthSubcommand::Enable(args) => format!( + "auth.enable mode={} has_api_key={}", + auth_mode_name(args.mode), + args.api_key.is_some() + ), + AuthSubcommand::Disable => "auth.disable".to_owned(), + AuthSubcommand::SetKey(_) => "auth.set-key has_api_key=true".to_owned(), + } +} + +fn auth_mode_name(mode: AuthMode) -> &'static str { + match mode { + AuthMode::Off => "off", + AuthMode::LocalOnly => "local-only", + AuthMode::Protected => "protected", + } +} + +fn config_command_summary(command: &ConfigCommand) -> String { + match &command.command { + ConfigSubcommand::Get(args) => format!("config.get key={}", args.key), + ConfigSubcommand::Set(args) => format!("config.set key={} value={}", args.key, args.value), + } +} + +fn bench_command_summary(command: &BenchCommand) -> String { + match &command.command { + BenchSubcommand::Throughput(args) => format!( + "bench.throughput samples={} prompt_tokens={} completion_tokens={}", + args.samples, args.prompt_tokens, args.completion_tokens + ), + BenchSubcommand::Smoke => "bench.smoke".to_owned(), + BenchSubcommand::Suite => "bench.suite".to_owned(), + BenchSubcommand::Compare(args) => { + format!( + "bench.compare baseline={} candidate={}", + args.baseline, args.candidate + ) + } } }