aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-11-06 10:19:54 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-11-06 10:19:54 -0800
commit7701c90fd67fe9598ba312cf0c0403c1d653bd75 (patch)
treeebab3147a84ec61dd7607fbd03af6b915aea537b /src/bin
parent4a07ef7d2789b0a58a4b892a9098e1e5cdcbb807 (diff)
downloadgeniza-7701c90fd67fe9598ba312cf0c0403c1d653bd75.tar.gz
geniza-7701c90fd67fe9598ba312cf0c0403c1d653bd75.zip
work in progress on drive import/export
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/geniza-drive.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/bin/geniza-drive.rs b/src/bin/geniza-drive.rs
index 7f945b0..79ba480 100644
--- a/src/bin/geniza-drive.rs
+++ b/src/bin/geniza-drive.rs
@@ -45,6 +45,12 @@ fn run() -> Result<()> {
.arg_from_usage("--target <path> 'path to import the file to (if not top level)'")
)
.subcommand(
+ SubCommand::with_name("export-file")
+ .about("Copies a file from dat archive to local disk")
+ .arg_from_usage("<FILE> 'file to export'")
+ .arg_from_usage("--target <path> 'path to save the file to (if not same name)'")
+ )
+ .subcommand(
SubCommand::with_name("log")
.about("History of additions/deletions from this dat")
)
@@ -61,7 +67,7 @@ fn run() -> Result<()> {
let dir = Path::new(matches.value_of("dat-dir").unwrap());
match matches.subcommand() {
("init", Some(_subm)) => {
- let drive = DatDrive::create(dir)?;
+ let _drive = DatDrive::create(dir)?;
// TODO: print public key in hex
println!("Done!");
}
@@ -82,6 +88,15 @@ fn run() -> Result<()> {
drive.import_file(&path, &fpath)?;
}
+ ("export-file", Some(subm)) => {
+ let path = Path::new(subm.value_of("FILE").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_file(&path, &fpath)?;
+ }
("cat", Some(subm)) => {
let path = Path::new(subm.value_of("FILE").unwrap());
let mut drive = DatDrive::open(dir, true)?;