Skip to content

Commit ed9d701

Browse files
committed
fix(cli): pluralize model counts correctly
1 parent 7954d02 commit ed9d701

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

src/cortex-cli/src/models_cmd.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,9 @@ async fn run_list(
533533
};
534534

535535
for (provider, models) in by_provider {
536-
println!("\n{} ({} models)", provider, models.len());
536+
let model_count = models.len();
537+
let model_label = model_count_label(model_count);
538+
println!("\n{} ({} {})", provider, model_count, model_label);
537539
println!("{}", "-".repeat(40));
538540
println!(
539541
"{:<width$} {:^6} {:^12} {:^8} {:^6}",
@@ -603,6 +605,14 @@ async fn run_list(
603605
Ok(())
604606
}
605607

608+
fn model_count_label(count: usize) -> &'static str {
609+
if count == 1 {
610+
"model"
611+
} else {
612+
"models"
613+
}
614+
}
615+
606616
#[cfg(test)]
607617
mod tests {
608618
use super::*;
@@ -631,6 +641,13 @@ mod tests {
631641
assert_eq!(result, ModelSortOrder::Provider);
632642
}
633643

644+
#[test]
645+
fn test_model_count_label() {
646+
assert_eq!(model_count_label(0), "models");
647+
assert_eq!(model_count_label(1), "model");
648+
assert_eq!(model_count_label(2), "models");
649+
}
650+
634651
#[test]
635652
fn test_model_sort_order_from_str_case_insensitive() {
636653
let upper: ModelSortOrder = "ID".parse().expect("parsing 'ID' should succeed");

0 commit comments

Comments
 (0)