add cli for usage and benchmarking
This commit is contained in:
parent
a9d81f015e
commit
3101c03211
4 changed files with 422 additions and 30 deletions
src
35
src/main.rs
35
src/main.rs
|
@ -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()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue