From 20c43a5f6a8565614c9c91b061bd65d2e4237c9d Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Sat, 22 Jan 2022 18:25:22 -0500 Subject: [PATCH] First commit that works --- README.adoc | 18 ++++++++++++++++++ src/main.rs | 8 ++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 README.adoc diff --git a/README.adoc b/README.adoc new file mode 100644 index 0000000..b359dc0 --- /dev/null +++ b/README.adoc @@ -0,0 +1,18 @@ += rust-selection-sort.kak + +== Configuration + +[source,title='kakrc'] +---- +define-command s -params 0..1 %{ + eval -save-regs '"' %{ + reg dquote %val{selections} + eval %sh{ + regex="${1:-.*}" + eval set -- "$kak_quoted_selections" + ~/syncthing/code/rust-selection-sort.kak/target/debug/rust-selection-sort "$regex" "$@" > "$kak_command_fifo" + } + exec R + } +} +---- diff --git a/src/main.rs b/src/main.rs index 3078dcb..e063f3b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,7 @@ use regex::Regex; use std::env; fn main() { let args = env::args().collect::>(); - assert!(args.len() < 2, "Usage: rust-selection-sort REGEX SEL1 [SEL2 ...]"); + assert!(args.len() > 2, "Usage: rust-selection-sort REGEX SEL1 [SEL2 ...]"); let replacement_re = &args[1]; @@ -28,9 +28,13 @@ fn main() { a.cmp(b) }); + print!("reg '\"'"); for i in &zipped { - print!("{}\0", i.0); + let new_selection = i.0.replace("'", "''"); + print!(" '{}'", new_selection); + // print!("{}\0", new_selection); // TODO: Allow debugging with -d // println!("\n\tSort key: {:?}", i.1); } + print!(" ;"); }