nix-configs/programs/flip-bool/src/main.rs

26 lines
626 B
Rust
Raw Normal View History

2025-03-10 14:22:10 +01:00
use std::io::{Read, Write};
fn main() {
let mut input = String::new();
let mut stdin = std::io::stdin();
let mut stdout = std::io::stdout();
stdin.read_to_string(&mut input).unwrap();
stdout
.write_all(match input.as_bytes() {
b"true" => b"false",
b"True" => b"False",
b"TRUE" => b"FALSE",
b"false" => b"true",
b"False" => b"True",
b"FALSE" => b"TRUE",
b"1" => b"0",
b"yes" => b"no",
b"0" => b"1",
b"no" => b"yes",
other => other,
})
.unwrap();
}