1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use clap::Parser;
use frame::cli::commands::{Cli, Commands};
use frame::cli::handlers;
fn main() {
let cli = Cli::parse();
let project_dir = cli.project_dir.clone();
match cli.command {
None => {
// No subcommand → launch TUI
if let Err(e) = frame::tui::run(project_dir.as_deref()) {
eprintln!("error: {}", e);
std::process::exit(1);
}
}
Some(Commands::Init(args)) => {
// Init is handled before project discovery
if let Err(e) = handlers::cmd_init(args) {
eprintln!("error: {}", e);
std::process::exit(1);
}
}
Some(Commands::Merge(args)) if args.resolve.is_empty() => {
// A merge driver's exit status *is* its result — 0 merged, 1
// conflicted, 2 declined — so it reports its own rather than being
// flattened into the generic error path. Runs before project
// discovery: it must neither lock the project nor register it.
std::process::exit(handlers::cmd_merge(args));
}
Some(_) => {
if let Err(e) = handlers::dispatch(cli) {
eprintln!("error: {}", e);
std::process::exit(1);
}
}
}
}