Add ID reporting in imag-bookmark

This commit is contained in:
Matthias Beyer 2018-10-06 12:36:31 +02:00
parent d1f087eb57
commit 344aae5f92

View file

@ -98,10 +98,18 @@ fn add(rt: &Runtime) {
.ok_or_else(|| format_err!("No bookmark collection '{}' found", coll)) .ok_or_else(|| format_err!("No bookmark collection '{}' found", coll))
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
let _ = rt
.report_touched(collection.get_location())
.map_err_trace_exit_unwrap(1);
for url in scmd.values_of("urls").unwrap() { // unwrap saved by clap for url in scmd.values_of("urls").unwrap() { // unwrap saved by clap
let _ = collection let new_ids = collection
.add_link(rt.store(), BookmarkLink::from(url)) .add_link(rt.store(), BookmarkLink::from(url))
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
let _ = rt
.report_all_touched(new_ids.into_iter())
.map_err_trace_exit_unwrap(1);
} }
info!("Ready"); info!("Ready");
@ -112,7 +120,8 @@ fn collection(rt: &Runtime) {
if scmd.is_present("add") { // adding a new collection if scmd.is_present("add") { // adding a new collection
let name = scmd.value_of("add").unwrap(); let name = scmd.value_of("add").unwrap();
if let Ok(_) = BookmarkCollectionStore::new(rt.store(), &name) { if let Ok(id) = BookmarkCollectionStore::new(rt.store(), &name) {
let _ = rt.report_touched(id.get_location()).map_err_trace_exit_unwrap(1);
info!("Created: {}", name); info!("Created: {}", name);
} else { } else {
warn!("Creating collection {} failed", name); warn!("Creating collection {} failed", name);
@ -139,6 +148,10 @@ fn list(rt: &Runtime) {
.ok_or_else(|| format_err!("No bookmark collection '{}' found", coll)) .ok_or_else(|| format_err!("No bookmark collection '{}' found", coll))
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
let _ = rt
.report_touched(collection.get_location())
.map_err_trace_exit_unwrap(1);
let links = collection.links(rt.store()).map_err_trace_exit_unwrap(1); let links = collection.links(rt.store()).map_err_trace_exit_unwrap(1);
debug!("Listing..."); debug!("Listing...");
for (i, link) in links.enumerate() { for (i, link) in links.enumerate() {
@ -148,8 +161,6 @@ fn list(rt: &Runtime) {
} }
}; };
debug!("... ready with listing"); debug!("... ready with listing");
info!("Ready");
} }
fn remove(rt: &Runtime) { fn remove(rt: &Runtime) {
@ -161,10 +172,18 @@ fn remove(rt: &Runtime) {
.ok_or_else(|| format_err!("No bookmark collection '{}' found", coll)) .ok_or_else(|| format_err!("No bookmark collection '{}' found", coll))
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
let _ = rt
.report_touched(collection.get_location())
.map_err_trace_exit_unwrap(1);
for url in scmd.values_of("urls").unwrap() { // enforced by clap for url in scmd.values_of("urls").unwrap() { // enforced by clap
collection let removed_links = collection
.remove_link(rt.store(), BookmarkLink::from(url)) .remove_link(rt.store(), BookmarkLink::from(url))
.map_err_trace_exit_unwrap(1); .map_err_trace_exit_unwrap(1);
let _ = rt
.report_all_touched(removed_links.into_iter())
.map_err_trace_exit_unwrap(1);
} }
info!("Ready"); info!("Ready");