2022-03-09 20:30:41 -05:00
|
|
|
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)]
|
2022-03-06 21:28:16 -05:00
|
|
|
pub struct Options;
|
|
|
|
pub fn shuf(_options: &Options) -> Result<KakMessage, KakMessage> {
|
2022-03-09 20:30:41 -05:00
|
|
|
let mut selections = get_selections()?;
|
2022-02-21 17:23:34 -05:00
|
|
|
let mut rng = thread_rng();
|
|
|
|
|
|
|
|
selections.shuffle(&mut rng);
|
|
|
|
|
2022-03-09 20:30:41 -05:00
|
|
|
set_selections(selections.iter())?;
|
2022-02-21 17:23:34 -05:00
|
|
|
|
|
|
|
Ok(KakMessage(
|
|
|
|
format!("Shuf {} selections", selections.len()),
|
|
|
|
None,
|
|
|
|
))
|
|
|
|
}
|