mod cli;
mod commands;
mod config;
mod git;
mod output;
mod remote;
mod urls;
mod validate;
use clap::Parser;
use cli::{Cli, Commands};
fn main() {
let cli = Cli::parse();
let result: Result<(), Box<dyn std::error::Error>> = match cli.command {
None => {
print_available_commands();
return;
}
Some(Commands::Setup) => commands::setup::run(),
Some(Commands::Set { key, value }) => commands::set::run(key, value),
Some(Commands::Init {
repo,
alias,
quiet,
debug,
}) => commands::init::run(repo, alias, quiet, debug),
Some(Commands::Shove) => commands::shove::run(),
};
if let Err(e) = result {
eprintln!("{} {e}", output::error_prefix());
std::process::exit(1);
}
}
fn print_available_commands() {
println!("entangle — easy setup for mirroring GitHub repos to Tangled.org");
println!();
println!("Commands:");
println!(" setup Interactive configuration of usernames and origin preference");
println!(" set Non-interactively set a single config value");
println!(" init Wire up GitHub and Tangled push remotes in this repo");
println!(" shove Push all branches and tags to both forges");
println!();
println!("Run `entangle <COMMAND> --help` for per-command usage.");
}