use clap::{Parser, Subcommand};
use std::path::PathBuf;
mod commands;
mod stats;
mod types;
mod utils;
use types::OutputFormat;
#[derive(Parser)]
#[command(name = "tallyhawk")]
#[command(about = "A sharp-eyed CLI tool for gathering project statistics")]
#[command(version = "0.1.0")]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Count {
#[arg(default_value = ".")]
path: PathBuf,
#[arg(short, long)]
all: bool,
#[arg(short, long, value_enum, default_value = "table")]
format: OutputFormat,
#[arg(long, default_value = "true")]
gitignore: bool,
#[arg(long)]
include_blanks: bool,
#[arg(long)]
include_comments: bool,
},
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
match cli.command {
Commands::Count {
path,
all,
format,
gitignore,
include_blanks,
include_comments,
} => {
let config = commands::count::CountConfig {
path,
include_hidden: all,
output_format: format,
respect_gitignore: gitignore,
include_blank_lines: include_blanks,
include_comments,
};
commands::count::run(config)?;
}
}
Ok(())
}