From 9ca88a1ecdad6c492e1d07f7fff77e199a5fefd0 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 24 Nov 2017 18:45:37 -0800 Subject: import/export drive directories --- src/bin/geniza-drive.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/bin/geniza-drive.rs') diff --git a/src/bin/geniza-drive.rs b/src/bin/geniza-drive.rs index d402539..42e06e2 100644 --- a/src/bin/geniza-drive.rs +++ b/src/bin/geniza-drive.rs @@ -51,6 +51,18 @@ fn run() -> Result<()> { .arg_from_usage(" 'file to export'") .arg_from_usage("--target 'path to save the file to (if not same name)'") ) + .subcommand( + SubCommand::with_name("import-dir") + .about("Adds a directory (recursively) to the dat") + .arg_from_usage(" 'directory to add'") + .arg_from_usage("--target 'path to import the file to (if not top level)'") + ) + .subcommand( + SubCommand::with_name("export-dir") + .about("Copies a directory (recursively) from dat archive to local disk") + .arg_from_usage(" 'directory to export'") + .arg_from_usage("--target 'path to save the directory to (if not same name)'") + ) .subcommand( SubCommand::with_name("log") .about("History of additions/deletions from this dat") @@ -122,6 +134,25 @@ fn run() -> Result<()> { }; drive.export_file(&path, &fpath)?; } + ("import-dir", Some(subm)) => { + let path = Path::new(subm.value_of("DIR").unwrap()); + let mut drive = DatDrive::open(dir, true)?; + let fpath = match subm.value_of("target") { + None => Path::new("/").join(path.file_name().unwrap()), + Some(p) => Path::new("/").join(p) + }; + drive.import_dir(&path, &fpath)?; + + } + ("export-dir", Some(subm)) => { + let path = Path::new(subm.value_of("DIR").unwrap()); + let mut drive = DatDrive::open(dir, true)?; + let fpath = match subm.value_of("target") { + None => Path::new("/").join(path.file_name().unwrap()), + Some(p) => Path::new("/").join(p) + }; + drive.export_dir(&path, &fpath)?; + } ("log", Some(_subm)) => { let mut drive = DatDrive::open(dir, false)?; for entry in drive.history(0) { -- cgit v1.2.3