use std::path::PathBuf;

use clap::{ArgAction, Parser};

/// CLI flags for the name generator binary.
#[derive(Debug, Clone, Parser)]
#[command(name = "name", about = "Crates.io name finder", version)]
pub struct CliArgs {
    /// Minimum candidate length (inclusive).
    #[arg(long)]
    pub min_len: Option<usize>,
    /// Maximum candidate length (inclusive).
    #[arg(long)]
    pub max_len: Option<usize>,
    /// Optional cap on how many available results to print.
    #[arg(long)]
    pub limit: Option<usize>,
    /// Enables bounded parallel checks.
    #[arg(long, action = ArgAction::SetTrue)]
    pub parallel: bool,
    /// Walk candidates alphabetically instead of shuffling.
    #[arg(long, action = ArgAction::SetTrue)]
    pub alphabetical: bool,
    /// Overrides the embedded dictionary with a newline-delimited file.
    #[arg(long)]
    pub dictionary: Option<PathBuf>,
    /// Restricts to embedded names only.
    #[arg(long, conflicts_with = "words_only")]
    pub names_only: bool,
    /// Restricts to embedded words only.
    #[arg(long, conflicts_with = "names_only")]
    pub words_only: bool,
    /// Enable verbose logging to stderr.
    #[arg(short, long, action = ArgAction::SetTrue)]
    pub verbose: bool,
    /// Disable the default maximum results cap (10).
    #[arg(long, action = ArgAction::SetTrue, conflicts_with = "limit")]
    pub no_limit: bool,
}

/// Parses CLI arguments using clap.
pub fn parse_args() -> CliArgs {
    CliArgs::parse()
}
