hooked/hooked-cli/source/main.rs

52 lines
1.0 KiB
Rust
Raw Normal View History

//! # Hooked
//!
//! > **Git hooks manager.**
#![forbid(unsafe_code)]
#![warn(missing_docs, clippy::missing_docs_in_private_items)]
use {
clap::Parser,
color_eyre::{install, Result},
hooked_config::Config,
};
use crate::cli::{Args, MainSubcommands};
/// The default template for all hooks.
pub const DEFAULT_TEMPLATE: &str = include_str!("templates/default.sh");
/// All supported hook types.
2022-10-30 20:14:12 +00:00
pub const HOOK_TYPES: [&str; 1] = ["pre-commit"];
mod cli;
2022-10-31 21:05:47 +00:00
mod utilities;
fn main() -> Result<()> {
install()?;
let args = Args::parse();
let config = Config::from_toml_file(args.config)?;
match args.command {
MainSubcommands::Install(sub_args) => {
cli::hooked_install(config, sub_args)?;
}
2022-10-28 18:24:07 +00:00
MainSubcommands::Uninstall(sub_args) => {
cli::hooked_uninstall(config, sub_args)?;
2022-10-28 18:24:07 +00:00
}
2022-10-30 20:14:12 +00:00
MainSubcommands::Run(sub_args) => {
cli::hooked_run(config, sub_args.hook_type)?;
2022-10-30 20:14:12 +00:00
}
#[cfg(debug_assertions)]
MainSubcommands::CliReference(sub_args) => {
cli::hooked_cli_reference(config, sub_args)?;
}
}
Ok(())
}