From 0af5d9117846c03d493e0fde9642fdbd1c91d7a4 Mon Sep 17 00:00:00 2001 From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr> Date: Wed, 11 May 2022 15:40:55 +0200 Subject: [PATCH] src/main.rs: add create-hooks subcommand --- src/main.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main.rs b/src/main.rs index e0f0e6c..e92f352 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,6 +2,7 @@ use clap::{Args, Parser, Subcommand}; mod checkout; mod commit; +mod create_hooks; mod init; mod list; @@ -31,6 +32,15 @@ enum Commands { /// Checkout results to the current git commit #[clap(alias = "co")] Checkout(Checkout), + /// Create github hooks to use gbl automaticaly after commit, before and afetr checkout + /// + /// This command should be used after git init and glb init. + /// This will create 3 hooks file: + /// 1. post-commit: `glb commit` will be launched after git commit + /// 2. pre-checkout: `glb pre-co` will be launched before git checkout + /// 3. post-checkout: `gbl checkout` will be launched after git checkout + #[clap(name = "create-hooks", alias = "ch")] + CreateHooks(CreateHooks), } #[derive(Debug, Args)] @@ -67,6 +77,13 @@ struct Checkout { mode: String, } +#[derive(Debug, Args)] +struct CreateHooks { + /// The compression that will automatically be used after each commit + #[clap(short, long, default_value = "lz4")] + compression: String, +} + fn main() { let args = Cli::parse(); @@ -86,5 +103,8 @@ fn main() { Commands::Checkout(co) => { checkout::checkout(&co.mode); } + Commands::CreateHooks(ch) => { + create_hooks::create_hooks(&ch.compression); + } } } -- GitLab