diff options
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/geniza-drive.rs | 31 |
1 files changed, 31 insertions, 0 deletions
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 @@ -52,6 +52,18 @@ fn run() -> Result<()> { .arg_from_usage("--target <path> '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("<DIR> 'directory to add'") + .arg_from_usage("--target <path> '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("<DIR> 'directory to export'") + .arg_from_usage("--target <path> '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) { |