Skip to content
Snippets Groups Projects
Commit 7f8e0911 authored by nfontrod's avatar nfontrod
Browse files

src/main.rs: update the main

parent b27ea5af
No related branches found
No related tags found
No related merge requests found
...@@ -3,10 +3,9 @@ use clap::{Args, Parser, Subcommand}; ...@@ -3,10 +3,9 @@ use clap::{Args, Parser, Subcommand};
mod checkout; mod checkout;
mod commit; mod commit;
mod create_hooks; mod create_hooks;
mod diff;
mod init; mod init;
mod list; mod list;
mod diff;
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
#[clap(name = "gbl")] #[clap(name = "gbl")]
...@@ -47,8 +46,11 @@ enum Commands { ...@@ -47,8 +46,11 @@ enum Commands {
" "
)] )]
CreateHooks(CreateHooks), CreateHooks(CreateHooks),
/// Remove the post-checkout and the post-commit hooks
#[clap(name = "delete-hooks", alias = "dh")]
DeleteHooks,
/// Show differences between two commits of the `results` folder /// Show differences between two commits of the `results` folder
Diff(Diff) Diff(Diff),
} }
#[derive(Debug, Args)] #[derive(Debug, Args)]
...@@ -75,8 +77,12 @@ struct Commit { ...@@ -75,8 +77,12 @@ struct Commit {
/// The compression used to save the results folder (no, lz4, zstd, zlib or lzma) /// 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")]
compression: String, compression: String,
/// Use this flag to update the content of the current commit archive if it has changed
#[clap(takes_value = false, short, long)] #[clap(takes_value = false, short, long)]
update: bool, update: bool,
/// Use this flag to revert your results folder like it was before for this commit
#[clap(takes_value = false, short, long)]
revert: bool,
} }
#[derive(Debug, Args)] #[derive(Debug, Args)]
...@@ -127,10 +133,9 @@ struct Diff { ...@@ -127,10 +133,9 @@ struct Diff {
/// If you leave this blank, /// If you leave this blank,
/// it will check the different between the commit1 and /// it will check the different between the commit1 and
/// your current result folder /// your current result folder
commit2: Option<String> commit2: Option<String>,
} }
fn main() { fn main() {
let args = Cli::parse(); let args = Cli::parse();
...@@ -139,7 +144,16 @@ fn main() { ...@@ -139,7 +144,16 @@ fn main() {
init::init_and_hook(init.hooks, &init.compression, &init.mode); init::init_and_hook(init.hooks, &init.compression, &init.mode);
} }
Commands::Commit(commit) => { Commands::Commit(commit) => {
if commit.revert {
if commit.revert == commit.update {
eprintln!("Error: You moust choose between --revert and --update option")
}
}
if !commit.revert {
commit::commit(commit.compression, String::from(""), commit.update); commit::commit(commit.compression, String::from(""), commit.update);
} else {
commit::revert_commit();
}
} }
Commands::List(list) => { Commands::List(list) => {
list::borg_list(list.first, list.last, &list.archive); list::borg_list(list.first, list.last, &list.archive);
...@@ -156,5 +170,8 @@ fn main() { ...@@ -156,5 +170,8 @@ fn main() {
Commands::Diff(diff) => { Commands::Diff(diff) => {
diff::compute_diff(&diff.commit1, &diff.commit2); diff::compute_diff(&diff.commit1, &diff.commit2);
} }
Commands::DeleteHooks => {
create_hooks::delete_hooks();
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment