only-engine 0.5.1

Execution planning and runtime engine for only tasks.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::path_lookup::command_exists_in_path;
use only_semantic::GuardKind;

pub(crate) fn probe_matches(kind: &GuardKind, argument: &str) -> bool {
    if argument.is_empty() {
        return false;
    }

    match kind {
        GuardKind::Os => std::env::consts::OS == argument,
        GuardKind::Arch => std::env::consts::ARCH == argument,
        GuardKind::Env => std::env::var_os(argument).is_some(),
        GuardKind::Has => command_exists_in_path(argument),
        GuardKind::Unknown(_) => false,
    }
}