aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-11-24 18:45:37 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-11-24 18:45:37 -0800
commit9ca88a1ecdad6c492e1d07f7fff77e199a5fefd0 (patch)
tree8ab695c63102700402eb7984d0099457cfd5a407 /src/bin
parent23a1fa44e8f69dedf23ea1e713a02b5112f9413a (diff)
downloadgeniza-9ca88a1ecdad6c492e1d07f7fff77e199a5fefd0.tar.gz
geniza-9ca88a1ecdad6c492e1d07f7fff77e199a5fefd0.zip
import/export drive directories
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/geniza-drive.rs31
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) {