diff --git a/src/main.rs b/src/main.rs index 10439a593045d262bcfaa9a22562d2d4e66ff835..e2ce19763916c170b579a98ca4ea7e76f6f1110c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,9 @@ +use crate::delete::Delete; use clap::{Args, Parser, Subcommand}; - mod checkout; mod commit; mod create_hooks; +mod delete; mod diff; mod init; mod list; @@ -39,12 +40,12 @@ enum Commands { name = "create-hooks", alias = "ch", long_about = "Create github hooks to use gbl automaticaly after commit, \ - before and after checkout \n \n\ - This command should be used after git init and glb init. \n \n\ - This will create 2 hooks file: \n\ - 1. post-commit: `glb commit` will be launched after git commit \n\ - 2. post-checkout: `gbl checkout` will be launched after git checkout - " + before and after checkout \n \n\ + This command should be used after git init and glb init. \n \n\ + This will create 2 hooks file: \n\ + 1. post-commit: `glb commit` will be launched after git commit \n\ + 2. post-checkout: `gbl checkout` will be launched after git checkout + " )] CreateHooks(CreateHooks), /// Remove the post-checkout and the post-commit hooks @@ -57,6 +58,10 @@ enum Commands { Mount(Mount), /// Unmount everything in the folder .mount Umount, + /// This command delete an archive from the repository or the complete repository + /// + /// This is basically a wrapper of the borg delete command + Delete(Delete), } #[derive(Debug, Args)] @@ -65,7 +70,7 @@ struct Init { #[clap(takes_value = false, short = 'H', long)] hooks: bool, /// The compression to use automatically at each commit if hooks are created - #[clap(short, long, default_value = "lz4")] + #[clap(short, long, default_value = "lz4", value_name = "COMPRESSION")] compression: String, /// The checkout mode used by gblk automatically after a git checkout: soft or hard. /// This option is only used if hooks are created. @@ -74,14 +79,14 @@ struct Init { /// those corresponding to the commit targeted by the checkout. /// /// The soft mode will only update files that existed in the targeted checkout - #[clap(short, long, default_value = "hard")] + #[clap(short, long, default_value = "hard", value_name = "MODE")] mode: String, } #[derive(Debug, Args)] struct Commit { /// The compression used to save the results folder (no, lz4, zstd, zlib or lzma) - #[clap(short, long, default_value = "lz4")] + #[clap(short, long, default_value = "lz4", value_name = "COMPRESSION")] compression: String, /// Use this flag to update the content of the current commit archive if it has changed #[clap(takes_value = false, short, long)] @@ -94,13 +99,13 @@ struct Commit { #[derive(Debug, Args)] struct List { /// consider first N archives - #[clap(short, long, default_value_t = 0)] + #[clap(short, long, default_value_t = 0, value_name = "N")] first: i32, /// consider last N archives - #[clap(short, long, default_value_t = 0)] + #[clap(short, long, default_value_t = 0, value_name = "N")] last: i32, /// If set list the files in this archive - #[clap(short, long, default_value = "")] + #[clap(short, long, default_value = "", value_name = "ARCHIVE")] archive: String, } @@ -112,14 +117,14 @@ struct Checkout { /// those corresponding to the commit targeted by the checkout. /// /// The soft mode will only update files that existed in the targeted checkout - #[clap(short, long, default_value = "soft")] + #[clap(short, long, default_value = "soft", value_name = "MODE")] mode: String, } #[derive(Debug, Args)] struct CreateHooks { /// The compression that will automatically be used after each commit - #[clap(short, long, default_value = "lz4")] + #[clap(short, long, default_value = "lz4", value_name = "COMPRESSION")] compression: String, /// The checkout mode used by gblk automatically after a git checkout: soft or hard. @@ -127,7 +132,7 @@ struct CreateHooks { /// those corresponding to the commit targeted by the checkout. /// /// The soft mode will only update files that existed in the targeted checkout - #[clap(short, long, default_value = "hard")] + #[clap(short, long, default_value = "hard", value_name = "MODE")] mode: String, } @@ -146,11 +151,11 @@ struct Diff { struct Mount { /// Commit name, sh: Glob is supported. This is an optional parameter: if /// not set then all commit archives will be mounted into the .mount directory - #[clap(short, long)] + #[clap(short, long, value_name = "COMMIT")] commit: Option<String>, /// The file/directory to extract. This is an optional parameter. If not set /// then all files in the archive will be displayed - #[clap(short, long)] + #[clap(short, long, value_name = "PATH")] path: Option<String>, /// If set, displays the .mount directory in 'version view'. /// @@ -160,7 +165,7 @@ struct Mount { /// - Version view: The `.mount` directory contains the results folder and /// every file within it becomes a directory storing every version of /// that file - #[clap(short, long)] + #[clap(short, long, takes_value = false)] versions: bool, /// Displays the differences between two files mounted corresponding to the /// given path. @@ -169,10 +174,10 @@ struct Mount { /// the current result folder /// /// This option is deactivated when used with --diff - #[clap(short, long)] + #[clap(short, long, takes_value = false)] diff: bool, /// Consider last N archive after other filter were applied - #[clap(short, long)] + #[clap(short, long, value_name = "N")] last: Option<u8>, } @@ -229,5 +234,8 @@ fn main() { Commands::Umount => { mount::umount_archive(false); } + Commands::Delete(my_delete) => { + delete::deletion_launcher(my_delete); + } } }