Skip to content

Commit

Permalink
Merge pull request #59 from sts10/upgrade
Browse files Browse the repository at this point in the history
Upgrade rand and itertools dependencies
  • Loading branch information
sts10 authored Jan 30, 2025
2 parents 34c482f + 6f806cd commit 888abed
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 36 deletions.
74 changes: 57 additions & 17 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tidy"
version = "0.3.12"
version = "0.3.13"
authors = ["sts10 <[email protected]>"]
edition = "2021"
license = "MIT"
Expand All @@ -13,8 +13,8 @@ categories = ["command-line-utilities"]
clap = { version = "4.5.18", features = ["derive"] }
memchr = "2.7.4"
radix_fmt = "1.0.0"
rand = "0.8.5"
itertools = "0.13.0"
rand = "0.9.0"
itertools = "0.14.0"
unicode-normalization = "0.1.24"
unicode-segmentation = "1.12.0"
icu = "1.5.0"
Expand Down
21 changes: 11 additions & 10 deletions readme.markdown
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Tidy
[![](https://deps.rs/repo/github/sts10/tidy/status.svg)](https://deps.rs/repo/github/sts10/tidy)

A command-line tool for combining and cleaning large word list files.

Expand Down Expand Up @@ -330,14 +331,6 @@ Check the [GitHub Releases page](https://github.com/sts10/tidy/releases) for bin

To install the executable on a Linux/macOS machine, download the `tidy` executable and move it to somewhere in your `$PATH`, like `$HOME/.local/bin` (you can do this on the command line with something like `mv ~/Downloads/tidy ~/.local/bin/`).

## For Tidy developers

* Run all code tests: `cargo test`
* Generate docs: `cargo doc --document-private-items --no-deps`. Add `--open` flag to open docs after generation. Locally, docs are printed to `./target/doc/tidy/index.html`.
* Check license compatibility of Tidy's dependencies: `cargo deny check licenses` (requires that you [have cargo-deny installed locally](https://github.com/EmbarkStudios/cargo-deny#install-cargo-deny))

Pull Requests welcome!

## Tidy can print attributes about a word list

**Note when using Tidy to audit a list**: Tidy will remove blank lines and duplicate lines (words) _before_ calculating these list attributes. For example, if you're 4,000-word list has, say, 5 duplicate words, Tidy will report that the list has 3,995 words. No warning of duplicate words is given.
Expand Down Expand Up @@ -526,11 +519,19 @@ Tidy's function for removing characters on either side of a given delimiter uses

See [this repo](https://github.com/sts10/splitter) for more information.

## For developers: How to create a release
## For Tidy developers

* Run all code tests: `cargo test`
* Generate docs: `cargo doc --document-private-items --no-deps`. Add `--open` flag to open docs after generation. Locally, docs are printed to `./target/doc/tidy/index.html`.
* Check license compatibility of Tidy's dependencies: `cargo deny check licenses` (requires that you [have cargo-deny installed locally](https://github.com/EmbarkStudios/cargo-deny#install-cargo-deny))

Pull Requests welcome!

### How to create a release

This project uses [cargo-dist](https://opensource.axo.dev/cargo-dist/) to create releases.

Some of [my personal docs are here](https://sts10.github.io/docs/cargo-dist-tips.html); but basically, `cargo install cargo-dist`. When you're ready to cut a new release, test the current state of the project with `cargo dist build` and `cargo dist plan`. If that went well, create a new git tag that matches the current project version in `Cargo.toml` with `git tag vX.X.X`. Finally, run `git push --tags` to kick off the release process. GitHub will handle it from here -- check your project's GitHub Releases page in about 5 to 10 minutes.
Some of [my personal docs are here](https://sts10.github.io/docs/cargo-dist-tips.html); but basically, `cargo install cargo-dist`. When you're ready to cut a new release, test the current state of the project with `dist build` and `dist plan`. If that went well, create a new git tag that matches the current project version in `Cargo.toml` with `git tag vX.X.X`. Finally, run `git push --tags` to kick off the release process. GitHub will handle it from here -- check your project's GitHub Releases page in about 5 to 10 minutes.

## Appendix: Tools that seem similar to Tidy
- [cook](https://github.com/giteshnxtlvl/cook): "An overpower[ed] wordlist generator, splitter, merger, finder, saver, create words permutation and combinations, apply different encoding/decoding and everything you need." Written in Go.
Expand Down
4 changes: 2 additions & 2 deletions src/display_information/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ fn make_list_free_of_metadata(
}
}

use rand::seq::SliceRandom;
use rand::prelude::IndexedRandom;
/// Print 5 sample 6-word passphrases from the newly created
/// word list.
pub fn generate_samples(list: &[String]) -> Vec<String> {
let mut samples: Vec<String> = vec![];
for _n in 0..30 {
match list.choose(&mut rand::thread_rng()) {
match list.choose(&mut rand::rng()) {
Some(word) => samples.push(word.to_string()),
None => panic!("Couldn't pick a random word"),
}
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use icu::locid::Locale;
use rand::seq::SliceRandom;
use rand::thread_rng;
use rand::prelude::SliceRandom;
use rand::rng;
pub mod cards;
pub mod dice;
pub mod display_information;
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn tidy_list(req: TidyRequest) -> Vec<String> {
};
list_to_tidy = match req.take_rand {
Some(amount_to_take) => {
let mut rng = thread_rng();
let mut rng = rng();
list_to_tidy.shuffle(&mut rng);
list_to_tidy.truncate(amount_to_take);
list_to_tidy
Expand Down Expand Up @@ -317,7 +317,7 @@ pub fn tidy_list(req: TidyRequest) -> Vec<String> {
// And/or can do so randomly
tidied_list = match req.print_rand {
Some(amount_to_cut) => {
let mut rng = thread_rng();
let mut rng = rng();
tidied_list.shuffle(&mut rng);
tidied_list.truncate(amount_to_cut);
tidied_list
Expand Down

0 comments on commit 888abed

Please sign in to comment.