human_ids

Generate human-readable IDs

2 releases

0.1.1 Feb 25, 2024
0.1.0 Feb 25, 2024


Used in human-ids-bin

MIT license

17KB
216 lines

human-ids

GitHub Actions Status Crates Crates

Create simple human readable IDs

Table of Contents

What?

This is a Rust "fork" of the TypeScript/JavaScript library human-id written by RienNeVaPlus, just rewritten in Rust. Used to generate friendly IDs like those used in changesets. Can be used either as a library or a binary.

Library

Installation

  1. Add id: cargo add human_ids
  2. Use it: use human_ids::generate(None)

Usage

For usage documentation, see the docs.rs page.

Binary

Usage

$ human_ids -h
Usage: human_ids [OPTIONS]

Options:
      --completion <COMPLETION>
          Generate shell completion scripts [possible values: bash, elvish, fish, powershell, zsh]
  -s, --separator <SEPARATOR>
          The separator to use between words [default: -]
  -c, --capitalize
          Capitalize each word
  -a, --adverb
          Add an adverb
  -n, --num-adjectives <NUM_ADJECTIVES>
          The number of adjectives to use [default: 1]
  -h, --help
          Print help (see more with '--help')
  -V, --version
          Print version

$ human_ids -s '~' -c
Happy~Mirrors~Matter

Completion

If your method of installation didn't include shell completion, you can manually source or save them with the human_ids --completion <shell> command.

Help

Finally, help is always available with human-ids -h (or --help if your installation included man pages).

Installation

Currently, the package is available a couple of places, including Homebrew, AUR and Nix.

Cargo
cargo install human-ids-bin
Homebrew
  1. brew tap sondr3/homebrew-taps
  2. brew install human-ids-bin

You can also download the matching release from the release tab, extracting the archive and placing the binary in your $PATH. Note that for Linux the unknown-linux-musl.tar.gz is preferred as it is statically linked and thus should run on any Linux distribution.

LICENSE

MIT.

Dependencies

~28KB