1pub mod commands;
19
20#[cfg(feature = "mcp")]
21pub mod server;
22
23use clap::{CommandFactory, Parser, Subcommand};
24use std::path::PathBuf;
25
26#[derive(Debug, Clone, Copy, Default, clap::ValueEnum)]
28pub enum ColorChoice {
29 #[default]
31 Auto,
32 Always,
34 Never,
36}
37
38impl ColorChoice {
39 pub fn apply(self) {
43 match self {
44 Self::Auto => {} Self::Always => owo_colors::set_override(true),
46 Self::Never => owo_colors::set_override(false),
47 }
48 }
49}
50
51const ENV_HELP: &str = "\
52ENVIRONMENT VARIABLES:
53 RUST_LOG Log filter (e.g., debug, bito-lint=trace)
54 BITO_LINT_LOG_PATH Explicit log file path
55 BITO_LINT_LOG_DIR Log directory
56";
57#[derive(Parser)]
59#[command(name = "bito-lint")]
60#[command(about = "Quality gate tooling for building-in-the-open artifacts", long_about = None)]
61#[command(version)]
62#[command(after_long_help = ENV_HELP)]
63pub struct Cli {
64 #[command(subcommand)]
66 pub command: Commands,
67
68 #[arg(short, long, global = true, value_name = "FILE")]
70 pub config: Option<PathBuf>,
71
72 #[arg(short = 'C', long, global = true)]
74 pub chdir: Option<PathBuf>,
75
76 #[arg(short, long, global = true)]
78 pub quiet: bool,
79
80 #[arg(short, long, global = true, action = clap::ArgAction::Count)]
82 pub verbose: u8,
83
84 #[arg(long, global = true, value_enum, default_value_t)]
86 pub color: ColorChoice,
87
88 #[arg(long, global = true)]
90 pub json: bool,
91}
92
93#[derive(Subcommand)]
95pub enum Commands {
96 Analyze(commands::analyze::AnalyzeArgs),
98
99 Tokens(commands::tokens::TokensArgs),
101
102 Readability(commands::readability::ReadabilityArgs),
104
105 Completeness(commands::completeness::CompletenessArgs),
107
108 Grammar(commands::grammar::GrammarArgs),
110
111 Doctor(commands::doctor::DoctorArgs),
113
114 Info(commands::info::InfoArgs),
116
117 #[cfg(feature = "mcp")]
119 Serve(commands::serve::ServeArgs),
120}
121
122pub fn command() -> clap::Command {
124 Cli::command()
125}