From 6b72bd64c0af7589dc25dd1df44800f71d98c35a Mon Sep 17 00:00:00 2001 From: vikingowl Date: Tue, 12 Aug 2025 06:00:10 +0200 Subject: [PATCH] Revert "[refactor] remove `dialoguer` dependency; migrate selection prompts to `cliclack`" This reverts commit df6faf64369b9418a5e31cddf0d88272cc46d0b8. --- Cargo.lock | 40 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 1 + src/lib.rs | 16 +++++++++++----- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8e88b5d..81f6c41 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -378,6 +378,19 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "dialoguer" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" +dependencies = [ + "console", + "shell-words", + "tempfile", + "thiserror", + "zeroize", +] + [[package]] name = "digest" version = "0.10.7" @@ -1160,6 +1173,7 @@ dependencies = [ "clap_mangen", "cliclack", "ctrlc", + "dialoguer", "indicatif", "libc", "reqwest", @@ -1477,6 +1491,12 @@ dependencies = [ "digest", ] +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shlex" version = "1.3.0" @@ -1605,6 +1625,26 @@ dependencies = [ "unicode-width", ] +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "tinystr" version = "0.8.1" diff --git a/Cargo.toml b/Cargo.toml index 661b71c..f2691c2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,6 +33,7 @@ whisper-rs = { git = "https://github.com/tazz4843/whisper-rs", default-features libc = "0.2" indicatif = "0.17" ctrlc = "3.4" +dialoguer = "0.11" cliclack = "0.3" [dev-dependencies] diff --git a/src/lib.rs b/src/lib.rs index 09f86c5..3d36458 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -615,21 +615,27 @@ where } printer(&"Multiple Whisper models found:".to_string()); - let mut display_names: Vec = Vec::with_capacity(candidates.len()); for (i, p) in candidates.iter().enumerate() { let name = p .file_name() .and_then(|s| s.to_str()) .map(|s| s.to_string()) .unwrap_or_else(|| p.display().to_string()); - display_names.push(name.clone()); printer(&format!(" {}) {}", i + 1, name)); } - // Print a blank line before the selection prompt to keep output synchronized. + // Print a blank line and the selection prompt using the provided printer to + // keep output synchronized with any active progress rendering. printer(""); - let idx = crate::ui::prompt_select_index("Select a Whisper model", &display_names) + let prompt = format!("Select model [1-{}]:", candidates.len()); + // UI: using dialoguer::Input for selection for now; migration to cliclack::Select may be considered later for consistency. + let sel: usize = dialoguer::Input::new() + .with_prompt(prompt) + .interact_text() .context("Failed to read selection")?; - let chosen = candidates.swap_remove(idx); + if sel == 0 || sel > candidates.len() { + return Err(anyhow!("Selection out of range")); + } + let chosen = candidates.swap_remove(sel - 1); let _ = std::fs::write(models_dir.join(".last_model"), chosen.display().to_string()); // Print an empty line after selection input printer("");