Add rev command
This commit is contained in:
parent
b714576b08
commit
caa3953f2c
@ -10,6 +10,7 @@
|
||||
#![feature(array_chunks)]
|
||||
|
||||
mod box_;
|
||||
mod rev;
|
||||
mod errors;
|
||||
mod incr;
|
||||
mod invert;
|
||||
@ -69,6 +70,8 @@ enum Commands {
|
||||
Decr(incr::Options),
|
||||
#[clap(about = "Decrement selections")]
|
||||
Incr(incr::Options),
|
||||
#[clap(about = "Reverse selectinos")]
|
||||
Rev(rev::Options)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
@ -119,5 +122,6 @@ fn run() -> Result<String, KakError> {
|
||||
Commands::Xlookup(o) => xlookup::xlookup(o),
|
||||
Commands::Incr(o) => incr::incr(o, true),
|
||||
Commands::Decr(o) => incr::incr(o, false),
|
||||
Commands::Rev(o) => rev::rev(o),
|
||||
}
|
||||
}
|
||||
|
11
src/rev.rs
Normal file
11
src/rev.rs
Normal file
@ -0,0 +1,11 @@
|
||||
use kakplugin::{get_selections, set_selections, KakError};
|
||||
#[derive(clap::StructOpt, Debug)]
|
||||
pub struct Options;
|
||||
|
||||
pub fn rev(_options: &Options) -> Result<String, KakError> {
|
||||
let selections = get_selections(None)?;
|
||||
|
||||
set_selections(selections.iter().rev())?;
|
||||
|
||||
Ok(format!("Reversed {} selections", selections.len()))
|
||||
}
|
Loading…
Reference in New Issue
Block a user