Argument handling

This commit is contained in:
femsci 2022-12-28 14:01:26 +01:00
parent 1bb1d6ba98
commit 80ddb74098
Signed by: femsci
GPG key ID: 08F7911F0E650C67

View file

@ -1,7 +1,18 @@
const FREQ_TABLE: &[char] = &['f', 'g', 'h', 'j', 'f', 'a', 's', 'd', 'k', 'l', 'g', 'u']; const FREQ_TABLE: &[char] = &['f', 'g', 'h', 'j', 'f', 'a', 's', 'd', 'k', 'l', 'g', 'u'];
fn main() { fn main() {
let len = std::env::args().nth(1).unwrap().parse::<usize>().unwrap(); let len: usize = std::env::args()
.nth(1)
.and_then(|x| {
let x = x.parse::<usize>();
if x.is_err() {
eprintln!("Argument is not a number...");
std::process::exit(-1);
}
Some(x.unwrap())
})
.or(Some(32))
.unwrap();
let mut last: char = '\0'; let mut last: char = '\0';