2022-10-28 17:39:15 +00:00
|
|
|
//! [`clap`] Derive structs.
|
|
|
|
|
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
use clap::{Parser, Subcommand};
|
|
|
|
|
2022-10-30 20:14:12 +00:00
|
|
|
mod run;
|
|
|
|
|
|
|
|
pub use run::hooked_run;
|
|
|
|
|
2022-10-28 17:39:15 +00:00
|
|
|
/// CLI arguments struct using [`clap::Parser`].
|
|
|
|
#[derive(Debug, Parser)]
|
|
|
|
#[clap(about, author, version)]
|
|
|
|
#[clap(propagate_version = true)]
|
|
|
|
pub struct Args {
|
|
|
|
/// The CLI subcommand.
|
|
|
|
#[clap(subcommand)]
|
|
|
|
pub command: MainSubcommands,
|
|
|
|
|
|
|
|
/// Path to a Hooked configuration.
|
|
|
|
#[clap(short, long, global = true, default_value = "Hooked.toml")]
|
|
|
|
pub config: PathBuf,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Main CLI subcommands.
|
|
|
|
#[derive(Debug, Subcommand)]
|
|
|
|
pub enum MainSubcommands {
|
|
|
|
/// Install Hooked into ".git/hooks".
|
|
|
|
Install {
|
|
|
|
/// Overwrite existing files.
|
2022-10-28 18:24:07 +00:00
|
|
|
#[clap(long)]
|
2022-10-28 17:39:15 +00:00
|
|
|
overwrite: bool,
|
|
|
|
},
|
2022-10-28 18:24:07 +00:00
|
|
|
|
|
|
|
/// Remove installed hooks.
|
|
|
|
Uninstall {
|
|
|
|
/// Remove hooks not installed by Hooked.
|
|
|
|
#[clap(long)]
|
|
|
|
all: bool,
|
|
|
|
},
|
2022-10-30 20:14:12 +00:00
|
|
|
|
|
|
|
/// Manually run hooks.
|
|
|
|
Run {
|
|
|
|
/// The hook type to run.
|
|
|
|
#[clap(value_parser = crate::HOOK_TYPES)]
|
|
|
|
hook_type: String,
|
|
|
|
},
|
2022-10-28 17:39:15 +00:00
|
|
|
}
|