unused-pub 0.1.3

A tool to detect unused public items (structs, enums, functions, etc.) in a Rust codebase.
Documentation
use clap::Parser;
use colored::*;
use std::path::PathBuf;
use unused_pub::run;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
    /// Path to the codebase to analyze
    #[arg(default_value = ".")]
    path: PathBuf,

    /// Verbose output
    #[arg(short, long)]
    verbose: bool,

    /// Filter by type (e.g. struct, enum, fn, const, trait, type)
    #[arg(short, long)]
    filter: Vec<String>,
}

fn main() {
    let args = Args::parse();

    let start = std::time::Instant::now();
    println!("{} {}", "Analyzing".green().bold(), args.path.display());

    match run(args.path, args.verbose, args.filter) {
        Ok(report) => {
            let duration = start.elapsed();
            println!("Analysis completed in {:.2?}", duration);

            if report.unused_items.is_empty() {
                println!("{}", "No unused public items found!".green());
            } else {
                println!("\n{}", "Unused Public Items:".yellow().bold());
                for item in report.unused_items {
                    println!(
                        "{} {} ({})",
                        item.kind.cyan(),
                        item.name.bold(),
                        item.location
                    );
                }
                println!("\nFound {} unused items.", report.count.to_string().red());
            }
        }
        Err(e) => {
            eprintln!("{} {}", "Error:".red().bold(), e);
            std::process::exit(1);
        }
    }
}