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};
mod checkout;
mod commit;
mod create_hooks;
mod diff;
mod init;
mod list;
mod diff;
#[derive(Debug, Parser)]
#[clap(name = "gbl")]
......@@ -47,8 +46,11 @@ enum Commands {
"
)]
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
Diff(Diff)
Diff(Diff),
}
#[derive(Debug, Args)]
......@@ -75,8 +77,12 @@ struct Commit {
/// The compression used to save the results folder (no, lz4, zstd, zlib or lzma)
#[clap(short, long, default_value = "lz4")]
compression: String,
/// Use this flag to update the content of the current commit archive if it has changed
#[clap(takes_value = false, short, long)]
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)]
......@@ -123,14 +129,13 @@ struct CreateHooks {
struct Diff {
/// The SHA1 of a commit
commit1: String,
/// The SHA1 of another commit.
/// If you leave this blank,
/// The SHA1 of another commit.
/// If you leave this blank,
/// it will check the different between the commit1 and
/// your current result folder
commit2: Option<String>
commit2: Option<String>,
}
fn main() {
let args = Cli::parse();
......@@ -139,7 +144,16 @@ fn main() {
init::init_and_hook(init.hooks, &init.compression, &init.mode);
}
Commands::Commit(commit) => {
commit::commit(commit.compression, String::from(""), commit.update);
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);
} else {
commit::revert_commit();
}
}
Commands::List(list) => {
list::borg_list(list.first, list.last, &list.archive);
......@@ -156,5 +170,8 @@ fn main() {
Commands::Diff(diff) => {
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