Revert "[refactor] remove dialoguer dependency; migrate selection prompts to cliclack"

This reverts commit df6faf6436.
This commit is contained in:
2025-08-12 06:00:10 +02:00
parent 278ca1b523
commit 6b72bd64c0
3 changed files with 52 additions and 5 deletions

40
Cargo.lock generated
View File

@@ -378,6 +378,19 @@ dependencies = [
"windows-sys 0.59.0", "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]] [[package]]
name = "digest" name = "digest"
version = "0.10.7" version = "0.10.7"
@@ -1160,6 +1173,7 @@ dependencies = [
"clap_mangen", "clap_mangen",
"cliclack", "cliclack",
"ctrlc", "ctrlc",
"dialoguer",
"indicatif", "indicatif",
"libc", "libc",
"reqwest", "reqwest",
@@ -1477,6 +1491,12 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]] [[package]]
name = "shlex" name = "shlex"
version = "1.3.0" version = "1.3.0"
@@ -1605,6 +1625,26 @@ dependencies = [
"unicode-width", "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]] [[package]]
name = "tinystr" name = "tinystr"
version = "0.8.1" version = "0.8.1"

View File

@@ -33,6 +33,7 @@ whisper-rs = { git = "https://github.com/tazz4843/whisper-rs", default-features
libc = "0.2" libc = "0.2"
indicatif = "0.17" indicatif = "0.17"
ctrlc = "3.4" ctrlc = "3.4"
dialoguer = "0.11"
cliclack = "0.3" cliclack = "0.3"
[dev-dependencies] [dev-dependencies]

View File

@@ -615,21 +615,27 @@ where
} }
printer(&"Multiple Whisper models found:".to_string()); printer(&"Multiple Whisper models found:".to_string());
let mut display_names: Vec<String> = Vec::with_capacity(candidates.len());
for (i, p) in candidates.iter().enumerate() { for (i, p) in candidates.iter().enumerate() {
let name = p let name = p
.file_name() .file_name()
.and_then(|s| s.to_str()) .and_then(|s| s.to_str())
.map(|s| s.to_string()) .map(|s| s.to_string())
.unwrap_or_else(|| p.display().to_string()); .unwrap_or_else(|| p.display().to_string());
display_names.push(name.clone());
printer(&format!(" {}) {}", i + 1, name)); 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(""); 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")?; .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()); let _ = std::fs::write(models_dir.join(".last_model"), chosen.display().to_string());
// Print an empty line after selection input // Print an empty line after selection input
printer(""); printer("");