v0.2.2 : suggestions d'installation selon l'OS (scoop/winget/apt/dnf/pacman/apk/brew) + README remanie
This commit is contained in:
+17
-4
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user