Default to alphanumeric sort
This commit is contained in:
parent
463aa8416d
commit
4b44d72765
@ -11,6 +11,7 @@ keywords = ["cli", "kakoune"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
regex = "1"
|
regex = "1"
|
||||||
clap = {version = "3", features = ["derive"]}
|
clap = {version = "3", features = ["derive"]}
|
||||||
|
alphanumeric-sort = "1"
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = true
|
lto = true
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
|
#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
|
||||||
|
|
||||||
|
use alphanumeric_sort::compare_str;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
|
|
||||||
@ -15,6 +16,8 @@ struct Options {
|
|||||||
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)]
|
||||||
|
lexicographic_sort: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
@ -25,6 +28,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn send_message(msg: &KakMessage) {
|
fn send_message(msg: &KakMessage) {
|
||||||
|
// TODO: This isn't echoing anything
|
||||||
let msg_str = msg.0.replace('\'', "''");
|
let msg_str = msg.0.replace('\'', "''");
|
||||||
print!("echo '{}';", msg_str);
|
print!("echo '{}';", msg_str);
|
||||||
|
|
||||||
@ -78,7 +82,12 @@ fn run() -> Result<(), KakMessage> {
|
|||||||
zipped.sort_by(|(a, a_key), (b, b_key)| {
|
zipped.sort_by(|(a, a_key), (b, b_key)| {
|
||||||
let a = a_key.unwrap_or(a);
|
let a = a_key.unwrap_or(a);
|
||||||
let b = b_key.unwrap_or(b);
|
let b = b_key.unwrap_or(b);
|
||||||
|
|
||||||
|
if options.lexicographic_sort {
|
||||||
a.cmp(b)
|
a.cmp(b)
|
||||||
|
} else {
|
||||||
|
compare_str(a, b)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
print!("reg '\"'");
|
print!("reg '\"'");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user