use clap::Parser; use std::io::BufRead; use std::io::Write; #[derive(Parser, Debug)] struct Args { #[arg(short)] decode: bool } fn main() { let args = Args::parse(); let mut stdin = std::io::stdin().lock(); let mut input = Vec::new(); stdin.read_until(0, &mut input).unwrap(); let output = if args.decode { let input = input.into_iter().filter(|s| s.is_ascii() && !s.is_ascii_whitespace()).collect::>(); base_keysmash::decode(&input[..]) } else { base_keysmash::encode(&input) }; std::io::stdout().lock().write_all(&output).unwrap(); }