use clap::{Args, Parser, Subcommand};
use clap_complete::Shell;

/// A tool to generate source code from DTOs and templates.
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None, arg_required_else_help = true)]
pub struct Cli {
    #[command(subcommand)]
    pub command: Option<Command>,

    #[command(flatten)]
    pub generate_args: GenerateArgs,
}

#[derive(Subcommand, Debug)]
pub enum Command {
    /// Generate shell completion script for the specified shell.
    Completion {
        #[arg(value_enum)]
        shell: Shell,
    },
}

#[derive(Args, Debug)]
pub struct GenerateArgs {
    /// Path to the directory containing DTO definition files and configuration CSVs.
    /// Also used as the template directory if --template-dir is not specified.
    #[arg(long, short = 'i', required = true)]
    pub input_dir: std::path::PathBuf,

    /// Path to the directory where generated files will be stored.
    #[arg(long, short = 'o', required = true)]
    pub output_dir: std::path::PathBuf,

    /// Path to the directory containing templates. If not specified, the input directory is used.
    #[arg(long, short = 't')]
    pub template_dir: Option<std::path::PathBuf>,

    /// (Optional) Path to a file containing a newline-separated list of DTO definition filenames to process.
    #[arg(long, short = 'l')]
    pub list_file: Option<std::path::PathBuf>,

    /// Enable verbose logging.
    #[arg(short, long)]
    pub verbose: bool,

    /// Do not clean the output directory before generation.
    #[arg(long)]
    pub keep: bool,

    /// Do not respect .gitignore files when processing templates (includes all files).
    #[arg(long)]
    pub no_gitignore: bool,
}
