pub(crate) mod explain;
pub(crate) mod handlers;
use std::path::PathBuf;
use clap::Parser;
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub(crate) enum OutputFormat {
#[default]
Text,
Json,
Github,
Dot,
Sarif,
Html,
Ai,
AiJson,
}
impl std::str::FromStr for OutputFormat {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"text" => Ok(Self::Text),
"json" => Ok(Self::Json),
"github" => Ok(Self::Github),
"dot" => Ok(Self::Dot),
"sarif" => Ok(Self::Sarif),
"html" => Ok(Self::Html),
"ai" => Ok(Self::Ai),
"ai-json" => Ok(Self::AiJson),
_ => Err(format!(
"Unknown format: {s}. Expected: text, json, github, dot, sarif, html, ai, ai-json"
)),
}
}
}
#[derive(Parser, Debug)]
#[command(
name = "rustqual",
about = "Structural quality analyzer for Rust — seven dimensions: IOSP, Complexity, DRY, SRP, Coupling, Test Quality, Architecture (with adapter call-parity).",
version
)]
pub(crate) struct Cli {
#[arg(default_value = ".")]
pub path: PathBuf,
#[arg(short, long)]
pub verbose: bool,
#[arg(long)]
pub findings: bool,
#[arg(long)]
pub json: bool,
#[arg(long, value_name = "FORMAT")]
pub format: Option<OutputFormat>,
#[arg(short, long)]
pub config: Option<PathBuf>,
#[arg(long)]
pub strict_closures: bool,
#[arg(long)]
pub strict_iterators: bool,
#[arg(long)]
pub allow_recursion: bool,
#[arg(long)]
pub strict_error_propagation: bool,
#[arg(long)]
pub no_fail: bool,
#[arg(long)]
pub fail_on_warnings: bool,
#[arg(long)]
pub init: bool,
#[arg(long, value_name = "SHELL")]
pub completions: Option<clap_complete::Shell>,
#[arg(long, value_name = "FILE")]
pub save_baseline: Option<PathBuf>,
#[arg(long, value_name = "FILE")]
pub compare: Option<PathBuf>,
#[arg(long)]
pub fail_on_regression: bool,
#[arg(long)]
pub watch: bool,
#[arg(long)]
pub suggestions: bool,
#[arg(long, value_name = "SCORE")]
pub min_quality_score: Option<f64>,
#[arg(long)]
pub sort_by_effort: bool,
#[arg(long, value_name = "REF", num_args = 0..=1, default_missing_value = "HEAD", conflicts_with = "watch")]
pub diff: Option<String>,
#[arg(long, value_name = "LCOV_FILE")]
pub coverage: Option<PathBuf>,
#[arg(long, value_name = "FILE")]
pub explain: Option<PathBuf>,
}