fix(cli): harden providers listing and keep provider map aligned
This commit is contained in:
parent
feaa4aba60
commit
ce23cbaeea
2 changed files with 239 additions and 32 deletions
20
src/main.rs
20
src/main.rs
|
|
@ -556,25 +556,37 @@ async fn main() -> Result<()> {
|
|||
|
||||
Commands::Providers => {
|
||||
let providers = providers::list_providers();
|
||||
let current = config.default_provider.as_deref().unwrap_or("openrouter");
|
||||
let current = config
|
||||
.default_provider
|
||||
.as_deref()
|
||||
.unwrap_or("openrouter")
|
||||
.trim()
|
||||
.to_ascii_lowercase();
|
||||
println!("Supported providers ({} total):\n", providers.len());
|
||||
println!(" {:<19} {}", "ID (use in config)", "DESCRIPTION");
|
||||
println!(" {:<19} {}", "───────────────────", "───────────");
|
||||
for p in &providers {
|
||||
let marker = if p.name == current { " (active)" } else { "" };
|
||||
let is_active = p.name.eq_ignore_ascii_case(¤t)
|
||||
|| p.aliases
|
||||
.iter()
|
||||
.any(|alias| alias.eq_ignore_ascii_case(¤t));
|
||||
let marker = if is_active { " (active)" } else { "" };
|
||||
let local_tag = if p.local { " [local]" } else { "" };
|
||||
let aliases = if p.aliases.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!(" (aliases: {})", p.aliases.join(", "))
|
||||
};
|
||||
println!(" {:<19} {}{}{}{}", p.name, p.display_name, local_tag, marker, aliases);
|
||||
println!(
|
||||
" {:<19} {}{}{}{}",
|
||||
p.name, p.display_name, local_tag, marker, aliases
|
||||
);
|
||||
}
|
||||
println!("\n custom:<URL> Any OpenAI-compatible endpoint");
|
||||
println!(" anthropic-custom:<URL> Any Anthropic-compatible endpoint");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Commands::Service { service_command } => service::handle_command(&service_command, &config),
|
||||
|
||||
Commands::Doctor => doctor::run(&config),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue