cache-lens 0.1.0

A static analyzer that detects cache-unfriendly Array-of-Structures (AoS) usage in Rust and suggests Structure-of-Arrays (SoA) refactors.
use clap::Parser;
use std::path::PathBuf;

/// Detects cache-unfriendly Array-of-Structures (AoS) usage and suggests
/// Structure-of-Arrays (SoA) refactors.
#[derive(Parser, Debug)]
#[command(name = "cache-lens", version, about, long_about = None)]
pub struct Cli {
    /// Rust source files or directories to scan (directories are walked
    /// recursively for *.rs files; `target/`, `.git/`, `node_modules/` are skipped)
    #[arg(required = true, num_args = 1..)]
    pub paths: Vec<PathBuf>,

    /// Minimum number of named fields a struct must declare to be considered
    /// a refactor candidate
    #[arg(long, default_value_t = 3)]
    pub min_fields: usize,

    /// Flag a loop when no more than this fraction (0.0-1.0) of the struct's
    /// fields are ever touched inside it
    #[arg(long, default_value_t = 0.5)]
    pub max_access_ratio: f64,

    /// Emit machine-readable JSON instead of the human-readable report
    #[arg(long)]
    pub json: bool,

    /// Exit with status code 1 if any findings are reported (useful in CI)
    #[arg(long)]
    pub strict: bool,

    /// Suppress the "scanning N files" progress line on stderr
    #[arg(short, long)]
    pub quiet: bool,
}

pub struct Config {
    pub min_fields: usize,
    pub max_access_ratio: f64,
}