#![cfg_attr(
test,
allow(
clippy::unwrap_used,
clippy::expect_used,
clippy::panic,
clippy::many_single_char_names
)
)]
use clap::FromArgMatches;
pub mod cli;
pub mod commands;
mod dispatch;
pub mod error;
pub mod hook_cache;
pub mod hook_forward;
pub mod hook_runtime;
pub mod hooks;
pub mod mcp_install;
pub mod runtime;
pub mod style;
use cli::{Cli, Commands, StatusLane};
pub async fn run() {
let _ = style::detect_color_support();
let matches = cli::build_cli().get_matches();
let cli = match Cli::from_arg_matches(&matches) {
Ok(c) => c,
Err(e) => {
e.exit();
}
};
let _ = difflore_core::startup::ensure_ready(false).await;
if let Err(e) = difflore_core::migration::run_if_needed().await {
eprintln!(
"[difflore] warning: retired per-project index migration refused old state ({e}). \
Run `difflore doctor --report` to inspect."
);
}
let command = if let Some(command) = cli.command {
command
} else {
match commands::welcome::first_run_path(cli.no_interactive).await {
commands::welcome::FirstRunPath::LaunchWizard => {
if !commands::welcome::run_wizard().await.should_continue_tui() {
return;
}
}
commands::welcome::FirstRunPath::ShowWelcome => {
if !commands::welcome::show_welcome_then_continue()
.await
.should_continue_tui()
{
return;
}
}
commands::welcome::FirstRunPath::Skip => {}
}
Commands::Status {
json: false,
lane: StatusLane::All,
}
};
Box::pin(dispatch::dispatch(command)).await;
}