diff --git a/src/main.rs b/src/main.rs index d6008ae9d3c2209c7d93da6da01c9505ceb87058..4725495da564cf512c6257d5dd1eecefd0d62b63 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ struct Cli { #[derive(Debug, Subcommand)] enum Commands { /// Initialize a borg repository inside a git project - Init, + Init(Init), /// Save the results folder of a git repository in an archive /// /// The archive will be named as the current commit in git @@ -48,6 +48,16 @@ enum Commands { CreateHooks(CreateHooks), } +#[derive(Debug, Args)] +struct Init { + /// If specified, hooks are created inside `.git/hooks repository` + #[clap(takes_value = false, short, long)] + hooks: bool, + /// The compression to use automatically at each commit if hooks are created + #[clap(short, long, default_value = "lz4")] + compression: String, +} + #[derive(Debug, Args)] struct Commit { /// The compression used to save the results folder (no, lz4, zstd, zlib or lzma) @@ -93,8 +103,8 @@ fn main() { let args = Cli::parse(); match args.commands { - Commands::Init => { - init::init_repository(); + Commands::Init(init) => { + init::init_and_hook(init.hooks, &init.compression); } Commands::Commit(commit) => { commit::commit(commit.compression, String::from(""), commit.update);