Impl remove()

This commit is contained in:
Matthias Beyer 2016-06-28 23:10:49 +02:00
parent 8eeb8bb310
commit 5bfdd5a827
2 changed files with 21 additions and 1 deletions

View file

@ -21,6 +21,9 @@ path = "../libimagref"
[dependencies.libimagerror] [dependencies.libimagerror]
path = "../libimagerror" path = "../libimagerror"
[dependencies.libimaginteraction]
path = "../libimaginteraction"
[dependencies.libimagentrylist] [dependencies.libimagentrylist]
path = "../libimagentrylist" path = "../libimagentrylist"

View file

@ -8,6 +8,7 @@ extern crate libimagrt;
extern crate libimagref; extern crate libimagref;
extern crate libimagerror; extern crate libimagerror;
extern crate libimagentrylist; extern crate libimagentrylist;
extern crate libimaginteraction;
mod ui; mod ui;
use ui::build_ui; use ui::build_ui;
@ -61,7 +62,23 @@ fn add(rt: &Runtime) {
} }
fn remove(rt: &Runtime) { fn remove(rt: &Runtime) {
unimplemented!() use libimagref::error::RefErrorKind;
use libimagerror::into::IntoError;
use libimaginteraction::ask::ask_bool;
let cmd = rt.cli().subcommand_matches("remove").unwrap();
let hash = cmd.value_of("hash").map(String::from).unwrap(); // saved by clap
let yes = cmd.is_present("yes");
if yes || ask_bool(&format!("Delete Ref with hash '{}'", hash)[..], None) {
match Ref::delete_by_hash(rt.store(), hash) {
Err(e) => trace_error(&e),
Ok(_) => info!("Ok"),
}
} else {
info!("Aborted");
}
} }
fn list(rt: &Runtime) { fn list(rt: &Runtime) {