aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-10-29 13:59:47 -0700
committerBryan Newbold <bnewbold@robocracy.org>2017-10-29 13:59:47 -0700
commit58a0dc3387cfc88991bd93fad6d16a84bd7e4902 (patch)
tree02f5f783815f7f13b830d4cf261dfdb103816923 /src/bin
parentad63a8f64fa434c25ecd9e5d3437f6885f586706 (diff)
downloadgeniza-58a0dc3387cfc88991bd93fad6d16a84bd7e4902.tar.gz
geniza-58a0dc3387cfc88991bd93fad6d16a84bd7e4902.zip
progress on drive: basic history dump (un-pretty output)
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/geniza-drive.rs70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/bin/geniza-drive.rs b/src/bin/geniza-drive.rs
new file mode 100644
index 0000000..05c7fb7
--- /dev/null
+++ b/src/bin/geniza-drive.rs
@@ -0,0 +1,70 @@
+// Free Software under GPL-3.0, see LICENSE
+// Copyright 2017 Bryan Newbold
+
+#[macro_use]
+extern crate clap;
+extern crate env_logger;
+#[macro_use]
+extern crate error_chain;
+extern crate geniza;
+
+// TODO: more careful import
+use geniza::*;
+use std::path::Path;
+use clap::{App, Arg, SubCommand};
+
+fn run() -> Result<()> {
+ env_logger::init().unwrap();
+
+ let matches = App::new("geniza-drive")
+ .version(env!("CARGO_PKG_VERSION"))
+ // TODO: dat-dir for all commands up here, and have a default vaule ('./dat')
+ .arg(Arg::with_name("dat-dir")
+ .short("d")
+ .long("dat-dir")
+ .value_name("PATH")
+ .help("dat drive directory")
+ .default_value(".dat") // TODO: needs to be default_value_os?
+ .takes_value(true))
+ .subcommand(
+ SubCommand::with_name("ls")
+ .about("Lists current files in this dat")
+ )
+ .subcommand(
+ SubCommand::with_name("log")
+ .about("History of additions/deletions from this dat")
+ )
+ .get_matches();
+
+/*
+ mode: ::std::option::Option<u32>,
+ uid: ::std::option::Option<u32>,
+ gid: ::std::option::Option<u32>,
+ size: ::std::option::Option<u64>,
+ blocks: ::std::option::Option<u64>,
+ offset: ::std::option::Option<u64>,
+ byteOffset: ::std::option::Option<u64>,
+ mtime: ::std::option::Option<u64>,
+ ctime: ::std::option::Option<u64>,
+*/
+
+ let dir = Path::new(matches.value_of("dat-dir").unwrap());
+ match matches.subcommand() {
+ ("ls", Some(_subm)) => {
+ }
+ ("log", Some(_subm)) => {
+ let mut drive = DatDrive::open(dir, false)?;
+ for entry in drive.history(1) {
+ println!("{:?}", entry?);
+ }
+ }
+ _ => {
+ println!("Missing or unimplemented command!");
+ println!("{}", matches.usage());
+ ::std::process::exit(-1);
+ }
+ }
+ Ok(())
+}
+
+quick_main!(run);