pub mod commands;
#[cfg(feature = "mcp")]
pub mod server;
use librebar::cli::clap::{Parser, Subcommand};
pub const EXIT_ISSUES_FOUND: u8 = 1;
pub const EXIT_TOOL_ERROR: u8 = 2;
#[derive(Debug, thiserror::Error)]
#[error("{0}")]
pub struct IssuesFound(pub String);
pub fn schema_metadata() -> librebar::cli::SchemaMetadata {
librebar::cli::SchemaMetadata::new()
.outcome(
librebar::cli::OutcomeMetadata::new(EXIT_ISSUES_FOUND, "issues_found")
.description("A check completed and the input did not meet a threshold"),
)
.error(
librebar::cli::ErrorMetadata::new("config_invalid")
.exit_code(EXIT_TOOL_ERROR)
.retryable(false)
.description("Configuration could not be discovered, parsed, or deserialized"),
)
.error(
librebar::cli::ErrorMetadata::new("input_rejected")
.exit_code(EXIT_TOOL_ERROR)
.retryable(false)
.description("Input was unreadable, oversized, or named an unknown check"),
)
}
const ENV_HELP: &str = "\
ENVIRONMENT VARIABLES:
RUST_LOG Log filter (e.g., debug, bito=trace)
BITO_LOG_PATH Log file path
BITO_LOG_DIR Log directory
BITO_TOKENIZER Tokenizer backend (claude, openai)
BITO_NO_UPDATE_CHECK Set to 1 to disable update checks
";
#[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(flatten)]
pub common: librebar::cli::CommonArgs,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[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),
}