diff --git a/src/main.rs b/src/main.rs index 35fea6b..d4057ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,8 +33,7 @@ fn app_args<'a> () -> clap::ArgMatches<'a> { .arg(Arg::with_name("reverse") .help("Reverse the order for assigned hints") .long("reverse") - .short("r") - .takes_value(true)) + .short("r")) .arg(Arg::with_name("excluded") .help("Excluded keys from the alphabet") .long("excluded") @@ -46,6 +45,7 @@ fn app_args<'a> () -> clap::ArgMatches<'a> { fn main() { let args = app_args(); let alphabet = args.value_of("alphabet").unwrap_or("querty"); + let reverse = args.is_present("reverse"); let execution = exec_command(format!("tmux capture-pane -e -J -p")); let output = String::from_utf8_lossy(&execution.stdout); @@ -70,7 +70,7 @@ fn main() { } let mut typed_hint: String = "".to_owned(); - let matches = state.matches(); + let matches = state.matches(reverse); let longest_hint = matches.last().unwrap().hint.clone().unwrap().len(); loop { diff --git a/src/state.rs b/src/state.rs index 0d221e4..1aec3b2 100644 --- a/src/state.rs +++ b/src/state.rs @@ -28,7 +28,7 @@ impl<'a> State<'a> { } } - pub fn matches(&self) -> Vec> { + pub fn matches(&self, reverse: bool) -> Vec> { let mut matches = Vec::new(); let mut patterns = Vec::new(); @@ -67,6 +67,10 @@ impl<'a> State<'a> { let alphabet = super::alphabets::get_alphabet(self.alphabet); let mut hints = alphabet.hints(matches.len()); + if reverse { + hints.reverse(); + } + for mat in &mut matches { if let Some(hint) = hints.pop() { mat.hint = Some(hint.to_string().clone()) diff --git a/tmux-thumbs.sh b/tmux-thumbs.sh index ffdd04c..6b24b71 100755 --- a/tmux-thumbs.sh +++ b/tmux-thumbs.sh @@ -1,3 +1,3 @@ #!/usr/bin/env bash -/home/ubuntu/dev/tmux-thumbs/target/debug/tmux-thumbs -a qwerty +/home/ubuntu/dev/tmux-thumbs/target/debug/tmux-thumbs -a qwerty -r