Add support for multiple binary names and idea having multiple binaries (#1167)

Add support for tools to have multiple possible binaries because IntellIj IDEA on the AUR can have multiple depending on the edition.

[AUR Ultimate Edition](https://aur.archlinux.org/packages/intellij-idea-ultimate-edition) and [AUR Community Edition](https://aur.archlinux.org/packages/intellij-idea-community-edition-bin) renames the binary to `intellij-idea-ultimate-edition` and `intellij-idea-community-edition` respectively.
This commit is contained in:
Stuart Reilly
2025-06-17 04:52:58 +01:00
committed by GitHub
parent 31fe5aa452
commit 845558c1da
3 changed files with 77 additions and 15 deletions

View File

@@ -112,6 +112,29 @@ pub fn require<T: AsRef<OsStr> + Debug>(binary_name: T) -> Result<PathBuf> {
}
}
pub fn require_one<T: AsRef<OsStr> + Debug>(binary_names: impl IntoIterator<Item = T>) -> Result<PathBuf> {
let mut failed_bins = Vec::new();
for bin in binary_names {
match require(&bin) {
Ok(path) => return Ok(path),
Err(_) => failed_bins.push(bin),
}
}
Err(SkipStep(format!(
"{}",
t!(
"Cannot find any of {binary_names} in PATH",
binary_names = failed_bins
.iter()
.map(|bin| format!("{:?}", bin))
.collect::<Vec<_>>()
.join(", ")
)
))
.into())
}
#[allow(dead_code)]
pub fn require_option<T>(option: Option<T>, cause: String) -> Result<T> {
if let Some(value) = option {