Lines
23.08 %
Functions
50 %
Branches
100 %
use std::io;
use clap::{Parser, Subcommand};
/// Delete local Git branches that have no remote counterpart.
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand, Debug)]
enum Command {
/// Delete orphaned local branches (default when no subcommand is given).
Run {
/// Continue without confirmation.
#[arg(short, long)]
yes: bool,
},
/// Install post-merge & post-rewrite hook to automatically run git-snip.
Install,
/// Main entry point for git-snip.
fn main() {
let cli = Cli::parse();
let result = match cli.command.unwrap_or(Command::Run { yes: false }) {
Command::Run { yes } => git_snip::snip(yes, io::stdin().lock()),
Command::Install => git_snip::install_hooks(),
};
if let Err(err) = result {
eprintln!("Error: {err}");
std::process::exit(1);
#[cfg(test)]
mod tests {
use super::*;
use clap::CommandFactory;
#[test]
fn verify_cli() {
Cli::command().debug_assert()