name-cli

Crates.ioname-cli
lib.rsname-cli
version0.1.1
created_at2025-12-08 05:11:53.724334+00
updated_at2025-12-08 06:06:07.703311+00
descriptionShared CLI parsing and prompts for the name generator workspace
homepagehttps://github.com/factordynamics/name
repositoryhttps://github.com/factordynamics/name
max_upload_size
id1972748
size58,657
refcell (refcell)

documentation

README

CLI Helpers

Shared command-line parsing and prompting for the name forge workspace. Flags are parsed with clap, then merged with interactive prompts to produce a ready-to-use GeneratorConfig.

Usage

use name_cli::{build_config, parse_args};
use name_crates_io_client::CratesClient;
use name_forge::{NameGenerator, NameStatus};

#[tokio::main]
async fn main() -> eyre::Result<()> {
    let args = parse_args();
    let config = build_config(args.clone())?; // Prompts for lengths/limits when omitted.

    let client = CratesClient::new("https://crates.io");
    let generator = NameGenerator::new(client);
    let results = generator.generate(&config).await?;

    let available: Vec<_> =
        results.into_iter().filter(|res| matches!(res.status, NameStatus::Available)).collect();
    println!("available: {available:?}");

    if args.verbose {
        eprintln!("checked {} candidates", results.len());
    }

    Ok(())
}

Flags and Defaults

  • --min-len <N> / --max-len <N>: inclusive bounds; prompted when missing (defaults 3 and 5).
  • --limit <N>: cap on available results (defaults to 10); --no-limit disables this cap.
  • --parallel: enable bounded parallel crates.io checks while preserving output order.
  • --alphabetical: disable shuffling for deterministic lexicographic scans; shuffle is the default.
  • --dictionary <path>: newline-delimited override for the embedded dictionary.
  • --names-only / --words-only: restrict to embedded names or words.
  • --verbose: enable tracing logs in the binary (exposed via CliArgs for callers).

Non-interactive runs fall back to defaults when prompts are not possible (e.g., piped input).

API

  • CliArgs::parse() returns parsed flags via clap.
  • build_config(args: CliArgs) -> eyre::Result<GeneratorConfig> merges flags with prompts and applies defaults (results cap, shuffle flag, dictionary selection).
Commit count: 0

cargo fmt