Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ Options:
--sudden-death Enable sudden death mode to restart on first error
--case-insensitive Ignore case when comparing typed input
--no-backspace Disable backspace/delete during test
--no-shuffle Don't shuffle word order
--no-limit Use entire word list (ignore --words limit)
--history Show history of past results
--last <N> Show only the last N history entries
--history-lang <LANG> Filter history by language
Expand Down
32 changes: 24 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ struct Opt {
#[arg(long)]
no_backspace: bool,

/// Don't shuffle word order
#[arg(long)]
no_shuffle: bool,

/// Use entire word list (ignore --words limit)
#[arg(long)]
no_limit: bool,

/// Show history of past results
#[arg(long)]
history: bool,
Expand Down Expand Up @@ -177,15 +185,23 @@ impl Opt {
})?
.lines()
.collect();
language.shuffle(&mut rng);
if !self.no_shuffle {
language.shuffle(&mut rng);
}

let mut contents: Vec<_> = language
.into_iter()
.cycle()
.take(self.words.get())
.map(ToOwned::to_owned)
.collect();
contents.shuffle(&mut rng);
let mut contents: Vec<_> = if self.no_limit {
language.into_iter().map(ToOwned::to_owned).collect()
} else {
language
.into_iter()
.cycle()
.take(self.words.get())
.map(ToOwned::to_owned)
.collect()
};
if !self.no_shuffle {
contents.shuffle(&mut rng);
}

Ok(contents)
}
Expand Down