diff --git a/README.adoc b/README.adoc index c9f2741..cd4cdcb 100644 --- a/README.adoc +++ b/README.adoc @@ -47,7 +47,7 @@ define-command sort-selections -params 0.. %{ # TODO: Send additional parameters - rust-selection-sort -r "$regex" $args -- "$@" > "$kak_command_fifo" + rust-selection-sort -R "$regex" $args -- "$@" > "$kak_command_fifo" } exec R } diff --git a/src/main.rs b/src/main.rs index 3adc2d6..d341dbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -12,12 +12,14 @@ struct Options { #[clap(short = 'S', long)] // TODO: Can we invert a boolean? This name is terrible no_skip_whitespace: bool, - #[clap(short, long, required = true)] + #[clap(short = 'R', long, required = true)] regex: String, #[clap(multiple_occurrences = true, required = true)] selections: Vec, #[clap(short, long)] lexicographic_sort: bool, + #[clap(short, long)] + reverse: bool, } fn main() { @@ -91,7 +93,14 @@ fn run() -> Result<(), KakMessage> { }); print!("reg '\"'"); - for i in &zipped { + + let iter: Box> = if options.reverse { + Box::new(zipped.iter().rev()) + } else { + Box::new(zipped.iter()) + }; + + for i in iter { let new_selection = i.0.replace('\'', "''"); print!(" '{}'", new_selection); }