use std::path::PathBuf;
use clap::{Args, Parser, ValueEnum};
#[derive(Parser, Debug)]
#[command(
name = "codelens",
author,
version,
about = "High performance code statistics tool",
after_help = EXAMPLES,
)]
pub struct Cli {
#[arg(default_value = ".")]
pub paths: Vec<PathBuf>,
#[command(flatten)]
pub filter: FilterArgs,
#[command(flatten)]
pub output: OutputArgs,
#[command(flatten)]
pub advanced: AdvancedArgs,
}
#[derive(Args, Debug)]
pub struct FilterArgs {
#[arg(short, long, value_delimiter = ',')]
pub lang: Option<Vec<String>>,
#[arg(long, value_delimiter = ',')]
pub exclude: Option<Vec<String>>,
#[arg(long)]
pub exclude_files: Option<String>,
#[arg(long)]
pub include_files: Option<String>,
#[arg(long)]
pub min_lines: Option<usize>,
#[arg(long)]
pub max_lines: Option<usize>,
#[arg(short, long)]
pub depth: Option<usize>,
#[arg(short, long)]
pub all: bool,
#[arg(long)]
pub no_gitignore: bool,
#[arg(long)]
pub no_smart_exclude: bool,
}
#[derive(Args, Debug)]
pub struct OutputArgs {
#[arg(short, long, value_enum, default_value = "console")]
pub format: OutputFormatArg,
#[arg(short = 'O', long)]
pub output_file: Option<PathBuf>,
#[arg(short, long)]
pub summary: bool,
#[arg(short, long)]
pub quiet: bool,
#[arg(short, long)]
pub verbose: bool,
#[arg(long, value_enum, default_value = "lines")]
pub sort: SortByArg,
#[arg(long)]
pub top: Option<usize>,
}
#[derive(Args, Debug)]
pub struct AdvancedArgs {
#[arg(short = 'j', long)]
pub threads: Option<usize>,
#[arg(short, long)]
pub config: Option<PathBuf>,
#[arg(long)]
pub no_config: bool,
#[arg(long)]
pub git_info: bool,
#[arg(long)]
pub list_languages: bool,
}
#[derive(ValueEnum, Clone, Copy, Debug, Default)]
pub enum OutputFormatArg {
#[default]
Console,
Json,
Csv,
Markdown,
Html,
}
#[derive(ValueEnum, Clone, Copy, Debug, Default)]
pub enum SortByArg {
#[default]
Lines,
Files,
Code,
Name,
Size,
}
const EXAMPLES: &str = r#"
Examples:
codelens # Analyze current directory
codelens src tests # Analyze multiple directories
codelens -l rust,go # Only count Rust and Go files
codelens -f json -O stats.json # Output JSON to file
codelens --exclude vendor,dist # Exclude directories
codelens --top 20 --sort code # Show top 20 by code lines
codelens --git-info # Include git information
codelens --list-languages # List supported languages
"#;