Add git version subcommand for rcore-fs-fuse

master
Jiajie Chen 6 years ago
parent 0508538490
commit 585eb6197a

@ -14,6 +14,7 @@ log = "0.4"
fuse = { version = "0.3", optional = true } fuse = { version = "0.3", optional = true }
structopt = "0.2" structopt = "0.2"
env_logger = "0.3" env_logger = "0.3"
git-version = "0.3"
rcore-fs = { path = "../rcore-fs", features = ["std"] } rcore-fs = { path = "../rcore-fs", features = ["std"] }
rcore-fs-sfs = { path = "../rcore-fs-sfs" } rcore-fs-sfs = { path = "../rcore-fs-sfs" }
rcore-fs-sefs = { path = "../rcore-fs-sefs", features = ["std"] } rcore-fs-sefs = { path = "../rcore-fs-sefs", features = ["std"] }

@ -12,6 +12,8 @@ use rcore_fs_fuse::zip::{unzip_dir, zip_dir};
use rcore_fs_sefs as sefs; use rcore_fs_sefs as sefs;
use rcore_fs_sfs as sfs; use rcore_fs_sfs as sfs;
use git_version::git_version;
#[derive(Debug, StructOpt)] #[derive(Debug, StructOpt)]
struct Opt { struct Opt {
/// Command /// Command
@ -45,6 +47,9 @@ enum Cmd {
#[cfg(feature = "use_fuse")] #[cfg(feature = "use_fuse")]
#[structopt(name = "mount")] #[structopt(name = "mount")]
Mount, Mount,
#[structopt(name = "git-version")]
GitVersion,
} }
fn main() { fn main() {
@ -57,6 +62,10 @@ fn main() {
Cmd::Mount => !opt.image.is_dir() && !opt.image.is_file(), Cmd::Mount => !opt.image.is_dir() && !opt.image.is_file(),
Cmd::Zip => true, Cmd::Zip => true,
Cmd::Unzip => false, Cmd::Unzip => false,
Cmd::GitVersion => {
println!("{}", git_version!());
return;
}
}; };
let fs: Arc<FileSystem> = match opt.fs.as_str() { let fs: Arc<FileSystem> = match opt.fs.as_str() {
@ -99,5 +108,6 @@ fn main() {
std::fs::create_dir(&opt.dir).expect("failed to create dir"); std::fs::create_dir(&opt.dir).expect("failed to create dir");
unzip_dir(&opt.dir, fs.root_inode()).expect("failed to unzip fs"); unzip_dir(&opt.dir, fs.root_inode()).expect("failed to unzip fs");
} }
Cmd::GitVersion => unreachable!(),
} }
} }

Loading…
Cancel
Save