mod commands;
mod git;
mod history;
mod tui;
use clap::{Parser, Subcommand};
use std::process::Command;
const PASSTHROUGH: &str = "Anything else is real git, passed straight through: slu commit -m \"fix\", slu push, slu rebase …
Run `slu <command> --help` for the full detail of any command.";
#[derive(Parser)]
#[command(
name = "sluuz",
bin_name = "slu",
version,
about = "git, but it sleuths — a git superset with cross-repo & history superpowers",
after_help = PASSTHROUGH,
arg_required_else_help = true
)]
struct Cli {
#[command(subcommand)]
command: Cmd,
}
#[derive(Subcommand)]
enum Cmd {
#[command(verbatim_doc_comment)]
Search(commands::search::Args),
#[command(verbatim_doc_comment)]
Scan(commands::scan::Args),
#[command(verbatim_doc_comment)]
Repos(commands::repos::Args),
#[command(verbatim_doc_comment)]
Sync(commands::sync::Args),
#[command(verbatim_doc_comment)]
Tidy(commands::tidy::Args),
#[command(verbatim_doc_comment)]
Itidy(commands::itidy::Args),
Each(commands::each::Args),
#[command(verbatim_doc_comment)]
Trace(commands::trace::Args),
#[command(verbatim_doc_comment)]
Ilog(commands::ilog::Args),
#[command(verbatim_doc_comment)]
Ibranch(commands::ibranch::Args),
#[command(verbatim_doc_comment)]
Istatus(commands::istatus::Args),
#[command(verbatim_doc_comment)]
Update(commands::update::Args),
#[command(verbatim_doc_comment)]
Completions(commands::completions::Args),
#[command(external_subcommand)]
Git(Vec<String>),
}
fn main() {
let cli = Cli::parse();
match cli.command {
Cmd::Search(args) => commands::search::run(args),
Cmd::Scan(args) => commands::scan::run(args),
Cmd::Repos(args) => commands::repos::run(args),
Cmd::Sync(args) => commands::sync::run(args),
Cmd::Tidy(args) => commands::tidy::run(args),
Cmd::Itidy(args) => commands::itidy::run(args),
Cmd::Each(args) => commands::each::run(args),
Cmd::Trace(args) => commands::trace::run(args),
Cmd::Ilog(args) => commands::ilog::run(args),
Cmd::Ibranch(args) => commands::ibranch::run(args),
Cmd::Istatus(args) => commands::istatus::run(args),
Cmd::Update(args) => commands::update::run(args),
Cmd::Completions(args) => commands::completions::run(args),
Cmd::Git(args) => passthrough(&args),
}
}
fn passthrough(args: &[String]) -> ! {
match Command::new("git").args(args).status() {
Ok(status) => std::process::exit(status.code().unwrap_or(1)),
Err(e) => {
eprintln!("slu: could not run git: {e}");
std::process::exit(127);
}
}
}