Add abillity to reverse
This commit is contained in:
parent
4b44d72765
commit
af8724d5eb
@ -47,7 +47,7 @@ define-command sort-selections -params 0.. %{
|
|||||||
|
|
||||||
# TODO: Send additional parameters
|
# TODO: Send additional parameters
|
||||||
|
|
||||||
rust-selection-sort -r "$regex" $args -- "$@" > "$kak_command_fifo"
|
rust-selection-sort -R "$regex" $args -- "$@" > "$kak_command_fifo"
|
||||||
}
|
}
|
||||||
exec R
|
exec R
|
||||||
}
|
}
|
||||||
|
13
src/main.rs
13
src/main.rs
@ -12,12 +12,14 @@ struct Options {
|
|||||||
#[clap(short = 'S', long)]
|
#[clap(short = 'S', long)]
|
||||||
// TODO: Can we invert a boolean? This name is terrible
|
// TODO: Can we invert a boolean? This name is terrible
|
||||||
no_skip_whitespace: bool,
|
no_skip_whitespace: bool,
|
||||||
#[clap(short, long, required = true)]
|
#[clap(short = 'R', long, required = true)]
|
||||||
regex: String,
|
regex: String,
|
||||||
#[clap(multiple_occurrences = true, required = true)]
|
#[clap(multiple_occurrences = true, required = true)]
|
||||||
selections: Vec<String>,
|
selections: Vec<String>,
|
||||||
#[clap(short, long)]
|
#[clap(short, long)]
|
||||||
lexicographic_sort: bool,
|
lexicographic_sort: bool,
|
||||||
|
#[clap(short, long)]
|
||||||
|
reverse: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -91,7 +93,14 @@ fn run() -> Result<(), KakMessage> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
print!("reg '\"'");
|
print!("reg '\"'");
|
||||||
for i in &zipped {
|
|
||||||
|
let iter: Box<dyn Iterator<Item = _>> = if options.reverse {
|
||||||
|
Box::new(zipped.iter().rev())
|
||||||
|
} else {
|
||||||
|
Box::new(zipped.iter())
|
||||||
|
};
|
||||||
|
|
||||||
|
for i in iter {
|
||||||
let new_selection = i.0.replace('\'', "''");
|
let new_selection = i.0.replace('\'', "''");
|
||||||
print!(" '{}'", new_selection);
|
print!(" '{}'", new_selection);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user