2022-03-09 22:17:22 -05:00
= kakutils-rs
2022-01-22 18:25:22 -05:00
2022-03-09 22:17:22 -05:00
Sort by regular expression or lexicographically, find uniqes, shuffle, or evaluate rust selections without spawning a new command for each.
2022-01-23 21:34:13 -05:00
== Example
. Imagine you want to sort these stages
+
[source,groovy]
----
stage('Package (#3)') {
// ...
}
stage('Build (#2)') {
// ...
}
stage('Initialize (#1)') {
// ...
}
stage('Publish (#4)') {}
----
. Select the stage and stage body with: `%sstage<ret>MLM`
2022-03-09 22:17:22 -05:00
. Sort the selection by step number with: `:utils sort #\d+<ret>` (sort on whole capture) or `:utils sort "'.+?#(\d).+?'"` (sort on first capture group, which contains only the digits)
. Note if you just run `:utils sort<ret>`
2022-01-23 21:34:13 -05:00
2022-01-22 18:25:22 -05:00
== Configuration
2022-01-23 21:30:07 -05:00
[source,sh,title='sh']
----
2022-03-09 22:17:22 -05:00
cargo install --git https://github.com/austenadler/kakutils-rs
2022-01-23 21:30:07 -05:00
----
2022-01-22 18:25:22 -05:00
[source,title='kakrc']
----
2022-03-09 22:17:22 -05:00
define-command utils -params 0.. %{
2022-01-22 18:25:22 -05:00
eval -save-regs '"' %{
reg dquote %val{selections}
eval %sh{
regex="${1:-.*}"
2022-02-12 22:50:30 -05:00
# use kak_command_fifo kak_response_fifo;
~/syncthing/code/kakutils-rs/target/debug/kakutils-rs sort "$regex" -- "$@"
2022-01-22 18:25:22 -05:00
}
exec R
}
}
----
2022-01-23 21:30:07 -05:00
== Usage
* Make multiple selections
2022-03-09 22:17:22 -05:00
* Run `utils sort` to sort the selections lexicographically
* Run `utils sort REGEX` to sort by regex match
2022-01-23 21:30:07 -05:00
** If the regex does not contain a capture group
** If the regex contains at least one capture group
== TODO
2022-03-09 22:17:22 -05:00
* I don't know what will happen with multiline strings and regex
2022-01-23 21:30:07 -05:00
* Figure out how to change the `no_skip_whitespace` option name in the source
2022-03-09 22:17:22 -05:00
* Get sort by selections working