summaryrefslogtreecommitdiff
path: root/cli/src/main.rs
diff options
context:
space:
mode:
authorstuebinm2024-01-23 01:57:07 +0100
committerstuebinm2024-01-23 02:04:13 +0100
commitb6a2783918dc4fce469394a01b6c98ff80c52ed6 (patch)
tree103426becb3640a2c8485904584e8aa288b918c3 /cli/src/main.rs
asdelafsljajkhsspkehdahslhlsdrssklwjolhjfksaoajhhkd
Diffstat (limited to '')
-rw-r--r--cli/src/main.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/src/main.rs b/cli/src/main.rs
new file mode 100644
index 0000000..77c56de
--- /dev/null
+++ b/cli/src/main.rs
@@ -0,0 +1,28 @@
+
+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::<Vec<u8>>();
+ base_keysmash::decode(&input[..])
+ } else {
+ base_keysmash::encode(&input)
+ };
+
+ std::io::stdout().lock().write_all(&output).unwrap();
+}