mod auth;
mod cli;
mod commands;
mod config;
mod git;
mod output;
mod providers;
mod skills;
mod update;
mod utils;
use anyhow::Result;
use clap::Parser;
use std::env;
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt()
.with_env_filter(
tracing_subscriber::EnvFilter::from_default_env()
.add_directive(tracing::Level::INFO.into()),
)
.init();
let args: Vec<String> = env::args().collect();
if commands::githook::is_hook_called(&args) {
return commands::githook::prepare_commit_msg_hook(&args).await;
}
let cli = cli::Cli::parse();
config::migrations::run_migrations()?;
utils::version::check_is_latest_version().await?;
match cli.command {
Some(cli::Commands::Config(cmd)) => commands::config::execute(cmd).await,
Some(cli::Commands::Hook(cmd)) => commands::githook::execute(cmd).await,
Some(cli::Commands::CommitLint(cmd)) => commands::commitlint::execute(cmd).await,
Some(cli::Commands::Auth(cmd)) => commands::auth::execute(cmd).await,
Some(cli::Commands::Mcp(cmd)) => commands::mcp::execute(cmd).await,
Some(cli::Commands::Update(cmd)) => commands::update::execute(cmd).await,
Some(cli::Commands::Pr(cmd)) => commands::pr::execute(cmd).await,
Some(cli::Commands::Model(cmd)) => commands::model::execute(cmd).await,
Some(cli::Commands::Setup(cmd)) => commands::setup::execute(cmd).await,
Some(cli::Commands::Completions(cmd)) => commands::completions::execute(cmd).await,
Some(cli::Commands::Skills(cmd)) => commands::skills::execute(cmd).await,
None => {
commands::commit::execute(cli.global).await
}
}
}