diff --git a/src/main.rs b/src/main.rs index 979e951..cf82245 100644 --- a/src/main.rs +++ b/src/main.rs @@ -166,34 +166,34 @@ fn push() { } fn input_parse(storage: &Storage, keybinds: &Keybinds, image_uri: &str) -> bool { - let key = std::io::stdin() - .lock() - .lines() - .next() - .unwrap() - .unwrap() - .chars() - .next() - .unwrap_or('_'); - match key { - 'b' | 'a' => { + loop { + let key = std::io::stdin() + .lock() + .lines() + .next() + .unwrap() + .unwrap() + .chars() + .next() + .unwrap_or('_'); + if &key == &keybinds.quit { + return true; + } else if &key == &keybinds.accept { let mut file = std::fs::OpenOptions::new() .write(true) .append(true) // This is needed to append to file .open(&storage.verified) .unwrap(); write!(file, "{}\n", image_uri).unwrap(); - } - 'q' => return true, - 'd' => { + return false; + } else if &key == &keybinds.delete { let mut file = std::fs::OpenOptions::new() .write(true) .append(true) // This is needed to append to file .open(&storage.rejected) .unwrap(); write!(file, "{}\n", image_uri).unwrap(); + return false; } - _ => return input_parse(storage, keybinds, image_uri), - }; - false + } }