add cli for usage and benchmarking

This commit is contained in:
askiiart 2025-01-15 17:07:11 -06:00
parent a9d81f015e
commit 3101c03211
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A
4 changed files with 422 additions and 30 deletions

View file

@ -1,32 +1,7 @@
extern crate cat2text;
use cat2text::base4;
use std::io::{self, stdout, Write};
#[cfg(feature = "bin")]
mod cli;
fn main() {
let stdin = io::stdin();
let mut input;
loop {
println!("Pick your translation:");
println!("1) cat to text");
println!("2) text to cat");
input = "".to_string();
stdin.read_line(&mut input).unwrap();
print!("~> ");
stdout().flush().unwrap();
let trimmed = input.trim();
if trimmed == "1".to_string() {
input = "".to_string();
stdin.read_line(&mut input).unwrap();
println!("{}", base4::decode(input.trim().to_string()));
} else if trimmed == "2".to_string() {
input = "".to_string();
stdin.read_line(&mut input).unwrap();
println!("{}", base4::encode(input.trim().to_string()));
} else {
println!("Invalid input, exiting...");
break;
}
println!();
}
}
#[cfg(feature = "bin")]
cli::run()
}