| Crates.io | name-cli |
| lib.rs | name-cli |
| version | 0.1.1 |
| created_at | 2025-12-08 05:11:53.724334+00 |
| updated_at | 2025-12-08 06:06:07.703311+00 |
| description | Shared CLI parsing and prompts for the name generator workspace |
| homepage | https://github.com/factordynamics/name |
| repository | https://github.com/factordynamics/name |
| max_upload_size | |
| id | 1972748 |
| size | 58,657 |
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.
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(())
}
--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).
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).