18 lines
473 B
Rust
Raw Normal View History

use crate::{get_selections, set_selections, KakMessage};
2022-02-21 18:30:32 -05:00
use rand::{seq::SliceRandom, thread_rng};
2022-02-21 17:23:34 -05:00
#[derive(clap::StructOpt, Debug)]
pub struct Options;
pub fn shuf(_options: &Options) -> Result<KakMessage, KakMessage> {
let mut selections = get_selections()?;
2022-02-21 17:23:34 -05:00
let mut rng = thread_rng();
selections.shuffle(&mut rng);
set_selections(selections.iter())?;
2022-02-21 17:23:34 -05:00
Ok(KakMessage(
format!("Shuf {} selections", selections.len()),
None,
))
}