From a66135b0c5d251a3123585c12a5fdd6925730be7 Mon Sep 17 00:00:00 2001
From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr>
Date: Thu, 1 Sep 2022 16:16:46 +0200
Subject: [PATCH] src/main.rs: update the main to handle the mount module

---
 src/main.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/main.rs b/src/main.rs
index d3c1563..45a552c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,6 +6,7 @@ mod create_hooks;
 mod diff;
 mod init;
 mod list;
+mod mount;
 
 #[derive(Debug, Parser)]
 #[clap(name = "gbl")]
@@ -51,6 +52,10 @@ enum Commands {
     DeleteHooks,
     /// Show differences between two commits of the `results` folder
     Diff(Diff),
+    /// Mount an old file/directory from one or multiple commits into the .mount folder inside de project directory.
+    Mount(Mount),
+    /// Unmount everything in the folder .mount
+    Umount,
 }
 
 #[derive(Debug, Args)]
@@ -136,6 +141,24 @@ struct Diff {
     commit2: Option<String>,
 }
 
+#[derive(Debug, Args)]
+struct Mount {
+    /// Commit name, sh: Glob is supported.
+    /// This is an optional parameter: if not set then all commits will be displayed
+    #[clap(short, long)]
+    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)]
+    path: Option<String>,
+    /// If set, displays the .mount directory in 'version view'.
+    ///
+    /// - Normal view: The mount directory contains a subfolder with the name of archives
+    /// - 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)]
+    versions: bool,
+}
+
 fn main() {
     let args = Cli::parse();
 
@@ -173,5 +196,11 @@ fn main() {
         Commands::DeleteHooks => {
             create_hooks::delete_hooks();
         }
+        Commands::Mount(mount) => {
+            mount::mount_archive(&mount.commit, &mount.path, mount.versions);
+        }
+        Commands::Umount => {
+            mount::umount_archive();
+        }
     }
 }
-- 
GitLab