From 58a0dc3387cfc88991bd93fad6d16a84bd7e4902 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 29 Oct 2017 13:59:47 -0700 Subject: progress on drive: basic history dump (un-pretty output) --- src/bin/geniza-drive.rs | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/bin/geniza-drive.rs (limited to 'src/bin/geniza-drive.rs') 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, + uid: ::std::option::Option, + gid: ::std::option::Option, + size: ::std::option::Option, + blocks: ::std::option::Option, + offset: ::std::option::Option, + byteOffset: ::std::option::Option, + mtime: ::std::option::Option, + ctime: ::std::option::Option, +*/ + + 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); -- cgit v1.2.3