From b6a2783918dc4fce469394a01b6c98ff80c52ed6 Mon Sep 17 00:00:00 2001 From: stuebinm Date: Tue, 23 Jan 2024 01:57:07 +0100 Subject: asdelafsljajkhsspkehdahslhlsdrssklwjolhjfksaoajhhkd --- cli/Cargo.toml | 10 ++++++++++ cli/src/main.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 cli/Cargo.toml create mode 100644 cli/src/main.rs (limited to 'cli') diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000..8ab1a10 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "base-keysmash-cli" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +base-keysmash = { path = "../lib" } +clap = { version = "4.4", features = [ "derive" ] } 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::>(); + base_keysmash::decode(&input[..]) + } else { + base_keysmash::encode(&input) + }; + + std::io::stdout().lock().write_all(&output).unwrap(); +} -- cgit v1.2.3