Skip to main content

require_tools

Function require_tools 

Source
pub fn require_tools(tools: &[(&str, &str, Option<&str>)]) -> Result<(), String>
Expand description

Check that a batch of external tools is available, returning a single error that lists every missing one with its install hint.

Each entry is (executable, install_hint, probe):

  • probe = Some(arg) runs <executable> <arg> (e.g. Some("--version"), or Some("version") for koji, or Some("--help") for pbuilder-dist) and requires a zero exit, confirming the tool actually executes.
  • probe = None checks only $PATH existence, for tools with no usable version/help flag.

All entries are checked, so the error names every missing tool rather than failing on the first.

ยงExample

sandogasa_cli::require_tools(&[
    ("git", "sudo apt install git", Some("--version")),
    ("pbuilder-dist", "sudo apt install ubuntu-dev-tools", Some("--help")),
])
.unwrap();