15 lines
432 B
Rust
15 lines
432 B
Rust
use kakplugin::{get_selections, set_selections, KakError};
|
|
use rand::{seq::SliceRandom, thread_rng};
|
|
#[derive(clap::StructOpt, Debug)]
|
|
pub struct Options;
|
|
pub fn shuf(_options: &Options) -> Result<String, KakError> {
|
|
let mut selections = get_selections(None)?;
|
|
let mut rng = thread_rng();
|
|
|
|
selections.shuffle(&mut rng);
|
|
|
|
set_selections(selections.iter())?;
|
|
|
|
Ok(format!("Shuf {} selections", selections.len()))
|
|
}
|