namesake

Crates.ionamesake
lib.rsnamesake
version0.1.0
created_at2025-08-05 17:46:13.04128+00
updated_at2025-08-05 17:46:13.04128+00
descriptionA CLI tool and library to generate names by combining words.
homepage
repositoryhttps://github.com/detj/namesake
max_upload_size
id1782366
size72,297
Debjeet Biswas (detj)

documentation

README

Namesake

A CLI tool and library to generate memorable names by combining words.

Namesake uses the CMU Pronouncing Dictionary to create new words. By default, it combines two random 3-letter, one-syllable words, but is highly configurable.

Features

  • Customizable Generation: Combine random words or use a specific word with --choice.
  • Syllable-based: Works with one-syllable (default) or two-syllable (--two) words.
  • Intelligent Fallback: Requesting a high --count automatically uses longer words after exhausting shorter ones.
  • Performant: Word lists are pre-processed at compile-time for fast, file-free execution at runtime.
  • Flexible Options: Generate all combinations (--all) or include reversed pairs (--reverse).
  • Usable as a Library: Integrate the core logic directly into your own Rust projects.

Installation

# Clone the repository
git clone https://github.com/detj/namesake.git
cd namesake

# Build the project (this downloads and processes the dictionary on the first run)
cargo build --release

The final executable is available at target/release/namesake.

CLI Usage

Command Description
./namesake Generates one name from two random 3-letter words.
./namesake --choice star Combines "star" with a random word (e.g., starship).
./namesake --count 5 Generates 5 random names.
./namesake --reverse Includes reversed combinations (e.g., catbat, batcat).
./namesake --two Uses two-syllable words instead of one-syllable words.
./namesake --all Generates all possible combinations of 3-letter words.

Flags can be combined, for example: namesake --choice bat --count 3 --reverse.

Library Usage

Add namesake to your Cargo.toml:

[dependencies]
namesake = "0.1.0" # Or use the git repository

Then, use the namesake function with a Config struct:

use namesake::{namesake, Config};

fn main() {
    // Generate 3 names based on the word "space", with reverses
    let config = Config {
        choice: Some("space".to_string()),
        count: 3,
        reverse: true,
        ..Default::default()
    };

    if let Ok(names) = namesake(&config) {
        println!("Generated names: {:?}", names);
    }
}

How It Works

The namesake crate contains both a library and a binary. A build.rs script downloads and processes the CMU Pronouncing Dictionary during compilation. The resulting word lists are embedded directly into the library using include_str!, ensuring the final binary is self-contained and fast.

Commit count: 0

cargo fmt