From 585eb6197aa687320618ee8c3c550a4e32aa9d15 Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Fri, 3 May 2019 14:50:52 +0800 Subject: [PATCH] Add git version subcommand for rcore-fs-fuse --- rcore-fs-fuse/Cargo.toml | 1 + rcore-fs-fuse/src/main.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/rcore-fs-fuse/Cargo.toml b/rcore-fs-fuse/Cargo.toml index cb2a53a..87402da 100644 --- a/rcore-fs-fuse/Cargo.toml +++ b/rcore-fs-fuse/Cargo.toml @@ -14,6 +14,7 @@ log = "0.4" fuse = { version = "0.3", optional = true } structopt = "0.2" env_logger = "0.3" +git-version = "0.3" rcore-fs = { path = "../rcore-fs", features = ["std"] } rcore-fs-sfs = { path = "../rcore-fs-sfs" } rcore-fs-sefs = { path = "../rcore-fs-sefs", features = ["std"] } diff --git a/rcore-fs-fuse/src/main.rs b/rcore-fs-fuse/src/main.rs index 0167900..3dbc9cb 100644 --- a/rcore-fs-fuse/src/main.rs +++ b/rcore-fs-fuse/src/main.rs @@ -12,6 +12,8 @@ use rcore_fs_fuse::zip::{unzip_dir, zip_dir}; use rcore_fs_sefs as sefs; use rcore_fs_sfs as sfs; +use git_version::git_version; + #[derive(Debug, StructOpt)] struct Opt { /// Command @@ -45,6 +47,9 @@ enum Cmd { #[cfg(feature = "use_fuse")] #[structopt(name = "mount")] Mount, + + #[structopt(name = "git-version")] + GitVersion, } fn main() { @@ -57,6 +62,10 @@ fn main() { Cmd::Mount => !opt.image.is_dir() && !opt.image.is_file(), Cmd::Zip => true, Cmd::Unzip => false, + Cmd::GitVersion => { + println!("{}", git_version!()); + return; + } }; let fs: Arc = match opt.fs.as_str() { @@ -99,5 +108,6 @@ fn main() { std::fs::create_dir(&opt.dir).expect("failed to create dir"); unzip_dir(&opt.dir, fs.root_inode()).expect("failed to unzip fs"); } + Cmd::GitVersion => unreachable!(), } }