1pub mod commands;
18
19#[cfg(feature = "mcp")]
20pub mod server;
21
22use clap::{CommandFactory, Parser, Subcommand};
23use std::path::PathBuf;
24
25#[derive(Debug, Clone, Copy, Default, clap::ValueEnum)]
27pub enum ColorChoice {
28 #[default]
30 Auto,
31 Always,
33 Never,
35}
36
37impl ColorChoice {
38 pub fn apply(self) {
42 match self {
43 Self::Auto => {} Self::Always => owo_colors::set_override(true),
45 Self::Never => owo_colors::set_override(false),
46 }
47 }
48}
49
50const ENV_HELP: &str = "\
51ENVIRONMENT VARIABLES:
52 RUST_LOG Log filter (e.g., debug, bito-lint=trace)
53 BITO_LINT_LOG_PATH Log file path (rotated daily)
54 BITO_LINT_LOG_DIR Log directory
55 BITO_LINT_TOKENIZER Tokenizer backend (claude, openai)
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, arg_required_else_help = true)]
62#[command(after_long_help = ENV_HELP)]
63pub struct Cli {
64 #[command(subcommand)]
66 pub command: Option<Commands>,
67
68 #[arg(long)]
70 pub version_only: bool,
71
72 #[arg(short, long, global = true, value_name = "FILE")]
74 pub config: Option<PathBuf>,
75
76 #[arg(short = 'C', long, global = true)]
78 pub chdir: Option<PathBuf>,
79
80 #[arg(short, long, global = true)]
82 pub quiet: bool,
83
84 #[arg(short, long, global = true, action = clap::ArgAction::Count)]
86 pub verbose: u8,
87
88 #[arg(long, global = true, value_enum, default_value_t)]
90 pub color: ColorChoice,
91
92 #[arg(long, global = true)]
94 pub json: bool,
95}
96
97#[derive(Subcommand)]
99pub enum Commands {
100 Analyze(commands::analyze::AnalyzeArgs),
102
103 Tokens(commands::tokens::TokensArgs),
105
106 Readability(commands::readability::ReadabilityArgs),
108
109 Completeness(commands::completeness::CompletenessArgs),
111
112 Grammar(commands::grammar::GrammarArgs),
114
115 Lint(commands::lint::LintArgs),
117
118 Doctor(commands::doctor::DoctorArgs),
120 Info(commands::info::InfoArgs),
122 #[cfg(feature = "mcp")]
124 Serve(commands::serve::ServeArgs),
125}
126
127pub fn command() -> clap::Command {
129 Cli::command()
130}