pub mod commands;
#[cfg(feature = "mcp")]
pub mod server;
use clap::{CommandFactory, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, Default, clap::ValueEnum)]
pub enum ColorChoice {
#[default]
Auto,
Always,
Never,
}
impl ColorChoice {
pub fn apply(self) {
match self {
Self::Auto => {} Self::Always => owo_colors::set_override(true),
Self::Never => owo_colors::set_override(false),
}
}
}
const ENV_HELP: &str = "\
ENVIRONMENT VARIABLES:
RUST_LOG Log filter (e.g., debug, bito=trace)
BITO_LOG_PATH Log file path (rotated daily)
BITO_LOG_DIR Log directory
BITO_TOKENIZER Tokenizer backend (claude, openai)
";
#[derive(Parser)]
#[command(name = "bito")]
#[command(about = "Quality gate tooling for building-in-the-open artifacts", long_about = None)]
#[command(version, arg_required_else_help = true)]
#[command(after_help = ENV_HELP)]
pub struct Cli {
#[command(subcommand)]
pub command: Option<Commands>,
#[arg(long)]
pub version_only: bool,
#[arg(short, long, global = true, value_name = "FILE")]
pub config: Option<PathBuf>,
#[arg(short = 'C', long, global = true)]
pub chdir: Option<PathBuf>,
#[arg(short, long, global = true)]
pub quiet: bool,
#[arg(short, long, global = true, action = clap::ArgAction::Count)]
pub verbose: u8,
#[arg(long, global = true, value_enum, default_value_t)]
pub color: ColorChoice,
#[arg(long, global = true)]
pub json: bool,
}
#[derive(Subcommand)]
pub enum Commands {
Analyze(commands::analyze::AnalyzeArgs),
Tokens(commands::tokens::TokensArgs),
Readability(commands::readability::ReadabilityArgs),
Completeness(commands::completeness::CompletenessArgs),
Grammar(commands::grammar::GrammarArgs),
Custom(commands::custom::CustomArgs),
Lint(commands::lint::LintArgs),
Doctor(commands::doctor::DoctorArgs),
Info(commands::info::InfoArgs),
#[cfg(feature = "mcp")]
Serve(commands::serve::ServeArgs),
}
pub fn command() -> clap::Command {
Cli::command()
}