pub(crate) mod dispatcher;
pub(crate) mod inspection;
pub(crate) mod supervisor;
pub(crate) mod terminal;
pub(crate) fn shell_allowed() -> bool {
std::env::var("NOMOREIDE_REMOTE_SHELL")
.map(|value| {
!matches!(
value.trim().to_ascii_lowercase().as_str(),
"0" | "false" | "no" | "off"
)
})
.unwrap_or(true)
}
pub(crate) fn disabled_by_environment() -> bool {
std::env::var("NOMOREIDE_REMOTE_DISABLED")
.map(|value| {
!matches!(
value.trim().to_ascii_lowercase().as_str(),
"" | "0" | "false"
)
})
.unwrap_or(false)
}
#[cfg(test)]
mod tests {
fn disabled(value: &str) -> bool {
!matches!(
value.trim().to_ascii_lowercase().as_str(),
"" | "0" | "false"
)
}
#[test]
fn the_switch_is_off_for_the_ways_people_write_off() {
for value in ["0", "false", "FALSE", " false ", ""] {
assert!(!disabled(value), "{value:?} should not disable");
}
}
#[test]
fn the_switch_is_on_for_the_ways_people_write_on() {
for value in ["1", "true", "TRUE", "yes", "on"] {
assert!(disabled(value), "{value:?} should disable");
}
}
}