pub fn detect(os: &str, on_path: &dyn Fn(&str) -> bool) -> BackendExpand description
Which backend a platform with these executables on its path runs. Pure: the platform and the lookup are given, so the decision is testable on any machine.
use majordomus_cli::mesh::firewall::{detect, Backend};
assert_eq!(detect("linux", &|name| name == "ufw" || name == "nft"), Backend::Ufw);
assert_eq!(detect("linux", &|name| name == "nft"), Backend::Nftables);
assert_eq!(detect("linux", &|_| false), Backend::None);
assert_eq!(detect("macos", &|_| false), Backend::ApplicationFirewall);
assert_eq!(detect("windows", &|_| true), Backend::None);