mod commands;
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[command(name = "weave", about = "Entity-level semantic merge for Git", version)]
struct Cli {
#[command(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Setup {
#[arg(long)]
driver: Option<String>,
#[arg(long)]
local: bool,
#[arg(long)]
global: bool,
},
Unsetup,
Apply {
files: Vec<String>,
},
Preview {
branch: String,
#[arg(long)]
file: Option<String>,
},
Status {
#[arg(long)]
file: Option<String>,
#[arg(long)]
agent: Option<String>,
},
Claim {
agent_id: String,
file_path: String,
entity_name: String,
},
Bench,
BenchRepo {
repo: String,
#[arg(long, default_value_t = 500)]
limit: usize,
#[arg(long)]
show_diff: bool,
#[arg(long)]
save: Option<String>,
},
Stats,
Summary {
file: String,
#[arg(long)]
json: bool,
},
Release {
agent_id: String,
file_path: String,
entity_name: String,
},
}
fn main() {
let cli = Cli::parse();
let result = match cli.command {
Commands::Setup {
ref driver,
local,
global,
} => commands::setup::run(driver.as_deref(), local, global),
Commands::Unsetup => commands::setup::unsetup(),
Commands::Apply { ref files } => commands::apply::run(files),
Commands::Preview {
ref branch,
ref file,
} => commands::preview::run(branch, file.as_deref()),
Commands::Status {
ref file,
ref agent,
} => commands::status::run(file.as_deref(), agent.as_deref()),
Commands::Bench => commands::bench::run(),
Commands::BenchRepo {
ref repo,
limit,
show_diff,
ref save,
} => commands::bench_repo::run(repo, limit, show_diff, save.as_deref()),
Commands::Stats => commands::stats::run(),
Commands::Summary { ref file, json } => commands::summary::run(file, json),
Commands::Claim {
ref agent_id,
ref file_path,
ref entity_name,
} => commands::claim::run(agent_id, file_path, entity_name),
Commands::Release {
ref agent_id,
ref file_path,
ref entity_name,
} => commands::release::run(agent_id, file_path, entity_name),
};
if let Err(e) = result {
eprintln!("Error: {}", e);
std::process::exit(1);
}
}