v0.2.2 : suggestions d'installation selon l'OS (scoop/winget/apt/dnf/pacman/apk/brew) + README remanie

This commit is contained in:
2026-08-15 12:56:33 -04:00
parent bd1d566a44
commit e513dd485d
9 changed files with 638 additions and 390 deletions
+17 -4
View File
@@ -136,11 +136,24 @@ pub fn sh_inherit(
Ok(())
}
/// Require a tool on the PATH, with an actionable error message.
/// Require a tool on the PATH, with an actionable error message that
/// includes the install command detected for the current OS.
pub fn require_tool(runner: &dyn Runner, tool: &str, hint: &str) -> Result<PathBuf> {
runner
.which(tool)
.ok_or_else(|| anyhow!("'{tool}' not found on PATH — install it first ({hint})"))
if let Some(p) = runner.which(tool) {
return Ok(p);
}
let os = crate::toolchain::OsInfo::detect();
let mut msg = format!("'{tool}' not found on PATH — install it first ({hint})");
let cmds = crate::toolchain::install_commands(tool, &os);
if !cmds.is_empty() {
msg.push_str(&format!(
"
on {}: {}",
os.name,
cmds.join(" | ")
));
}
Err(anyhow!(msg))
}
/// Detect a binary's version via --version, then -V.