use cuno_core::NameCase;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum HostOs {
Windows,
Other,
}
impl HostOs {
pub fn current() -> HostOs {
if cfg!(windows) {
HostOs::Windows
} else {
HostOs::Other
}
}
pub fn name_case(self) -> NameCase {
match self {
HostOs::Windows => NameCase::Insensitive,
HostOs::Other => NameCase::Sensitive,
}
}
pub fn executable(self, name: &str) -> String {
match self {
HostOs::Windows => format!("{name}.exe"),
HostOs::Other => name.to_owned(),
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn executables_are_named_for_the_host() {
assert_eq!(HostOs::Windows.executable("clang"), "clang.exe");
assert_eq!(HostOs::Other.executable("clang"), "clang");
}
}