From 3eb5e8283947782d9b0afa1a0873c289c5180d7a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 26 Jun 2016 11:39:27 +0200 Subject: [PATCH] Impl add() --- imag-ref/src/main.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index f16d7dcc..3a7694b3 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -33,7 +33,23 @@ fn main() { } fn add(rt: &Runtime) { - unimplemented!() + let cmd = rt.cli().subcommand_matches("add").unwrap(); + let path = cmd.value_of("path").map(PathBuf::from).unwrap(); // saved by clap + + let flags = RefFlags::default() + .with_content_hashing(cmd.is_present("track-content")) + .with_permission_tracking(cmd.is_present("track-permissions")); + + match Ref::create(rt.store(), path, flags) { + Ok(r) => { + debug!("Reference created: {:?}", r); + info!("Ok"); + }, + Err(e) => { + trace_error(&e); + warn!("Failed to create reference"); + }, + } } fn remove(rt: &Runtime) {