feat: enrich cli semantic summaries
This commit is contained in:
1 parent
a3f5585700
commit
50ee95ba1e
1 file changed
+83
-10
@@ -186,21 +186,94 @@ fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
fn render_command_summary(cli: &Cli) -> String {
|
fn render_command_summary(cli: &Cli) -> String {
|
||||||
format!(
|
format!(
|
||||||
"command={} server={}",
|
"command={} server={} format={} models_dir={}",
|
||||||
command_summary(&cli.command),
|
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 {
|
match command {
|
||||||
Commands::Status => "status",
|
Commands::Status => "status".to_owned(),
|
||||||
Commands::Models(_) => "models",
|
Commands::Models(models) => models_command_summary(models),
|
||||||
Commands::Auth(_) => "auth",
|
Commands::Auth(auth) => auth_command_summary(auth),
|
||||||
Commands::Config(_) => "config",
|
Commands::Config(config) => config_command_summary(config),
|
||||||
Commands::Bench(_) => "bench",
|
Commands::Bench(bench) => bench_command_summary(bench),
|
||||||
Commands::Logs(_) => "logs",
|
Commands::Logs(args) => format!("logs lines={}", args.lines),
|
||||||
Commands::Doctor => "doctor",
|
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
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user