use std::io;
use clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Command>,
}
#[derive(Subcommand, Debug)]
enum Command {
Run {
#[arg(short, long)]
yes: bool,
},
Install {
#[arg(short, long)]
force: bool,
},
}
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 { force } => git_snip::install_hooks(force),
};
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()
}
}