Merge branch 'more-touching' into master
This commit is contained in:
commit
d51c1e99b9
6 changed files with 45 additions and 22 deletions
|
@ -25,6 +25,7 @@ url = "2"
|
||||||
toml = "0.5.1"
|
toml = "0.5.1"
|
||||||
toml-query = "0.9.2"
|
toml-query = "0.9.2"
|
||||||
failure = "0.1.5"
|
failure = "0.1.5"
|
||||||
|
resiter = "0.4.0"
|
||||||
|
|
||||||
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
|
||||||
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
libimagrt = { version = "0.10.0", path = "../../../lib/core/libimagrt" }
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern crate log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure;
|
extern crate failure;
|
||||||
extern crate toml_query;
|
extern crate toml_query;
|
||||||
|
extern crate resiter;
|
||||||
|
|
||||||
extern crate libimagentryannotation;
|
extern crate libimagentryannotation;
|
||||||
extern crate libimagentryedit;
|
extern crate libimagentryedit;
|
||||||
|
@ -55,6 +56,9 @@ use failure::Error;
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
use failure::ResultExt;
|
use failure::ResultExt;
|
||||||
use failure::err_msg;
|
use failure::err_msg;
|
||||||
|
use resiter::IterInnerOkOrElse;
|
||||||
|
use resiter::AndThen;
|
||||||
|
use resiter::Map;
|
||||||
use toml_query::read::TomlValueReadTypeExt;
|
use toml_query::read::TomlValueReadTypeExt;
|
||||||
use clap::App;
|
use clap::App;
|
||||||
|
|
||||||
|
@ -67,6 +71,7 @@ use libimagrt::application::ImagApplication;
|
||||||
use libimagstore::store::FileLockEntry;
|
use libimagstore::store::FileLockEntry;
|
||||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||||
use libimagentrylink::linkable::Linkable;
|
use libimagentrylink::linkable::Linkable;
|
||||||
|
use libimagrt::iter::ReportTouchedResultEntry;
|
||||||
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
|
@ -121,12 +126,13 @@ fn add(rt: &Runtime) -> Result<()> {
|
||||||
|
|
||||||
annotation.edit_content(&rt)?;
|
annotation.edit_content(&rt)?;
|
||||||
|
|
||||||
for id in ids {
|
rt.report_touched(&first)?; // report first one first
|
||||||
let mut entry = rt.store().get(id.clone())?
|
ids.map(Ok).into_get_iter(rt.store())
|
||||||
.ok_or_else(|| format_err!("Not found: {}", id.local_display_string()))?;
|
.map_inner_ok_or_else(|| err_msg("Did not find one entry"))
|
||||||
|
.and_then_ok(|mut entry| entry.add_link(&mut annotation).map(|_| entry))
|
||||||
entry.add_link(&mut annotation)?;
|
.map_report_touched(&rt)
|
||||||
}
|
.map_ok(|_| ())
|
||||||
|
.collect::<Result<Vec<_>>>()?;
|
||||||
|
|
||||||
if !scmd.is_present("dont-print-name") {
|
if !scmd.is_present("dont-print-name") {
|
||||||
if let Some(annotation_id) = annotation
|
if let Some(annotation_id) = annotation
|
||||||
|
@ -139,6 +145,8 @@ fn add(rt: &Runtime) -> Result<()> {
|
||||||
.context("This is most likely a BUG, please report!")?;
|
.context("This is most likely a BUG, please report!")?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rt.report_touched(annotation.get_location())?;
|
||||||
} else {
|
} else {
|
||||||
debug!("No entries to annotate");
|
debug!("No entries to annotate");
|
||||||
}
|
}
|
||||||
|
@ -176,7 +184,7 @@ fn remove(rt: &Runtime) -> Result<()> {
|
||||||
debug!("Not deleting annotation object");
|
debug!("Not deleting annotation object");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
rt.report_touched(entry.get_location()).map_err(Error::from)
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -200,7 +208,9 @@ fn list(rt: &Runtime) -> Result<()> {
|
||||||
.into_get_iter(rt.store())
|
.into_get_iter(rt.store())
|
||||||
.map(|el| el.and_then(|o| o.ok_or_else(|| format_err!("Cannot find entry"))))
|
.map(|el| el.and_then(|o| o.ok_or_else(|| format_err!("Cannot find entry"))))
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, entry)| entry.and_then(|e| list_annotation(&rt, i, e, with_text)))
|
.map(|(i, entry)| entry.and_then(|e| list_annotation(&rt, i, &e, with_text).map(|_| e)))
|
||||||
|
.map_report_touched(&rt)
|
||||||
|
.map_ok(|_| ())
|
||||||
.collect())
|
.collect())
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
|
@ -212,12 +222,14 @@ fn list(rt: &Runtime) -> Result<()> {
|
||||||
.into_get_iter()
|
.into_get_iter()
|
||||||
.map(|el| el.and_then(|opt| opt.ok_or_else(|| format_err!("Cannot find entry"))))
|
.map(|el| el.and_then(|opt| opt.ok_or_else(|| format_err!("Cannot find entry"))))
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(i, entry)| entry.and_then(|e| list_annotation(&rt, i, e, with_text)))
|
.map(|(i, entry)| entry.and_then(|e| list_annotation(&rt, i, &e, with_text).map(|_| e)))
|
||||||
|
.map_report_touched(&rt)
|
||||||
|
.map_ok(|_| ())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn list_annotation<'a>(rt: &Runtime, i: usize, a: FileLockEntry<'a>, with_text: bool) -> Result<()> {
|
fn list_annotation<'a>(rt: &Runtime, i: usize, a: &FileLockEntry<'a>, with_text: bool) -> Result<()> {
|
||||||
if with_text {
|
if with_text {
|
||||||
writeln!(rt.stdout(),
|
writeln!(rt.stdout(),
|
||||||
"--- {i: >5} | {id}\n{text}\n\n",
|
"--- {i: >5} | {id}\n{text}\n\n",
|
||||||
|
|
|
@ -48,10 +48,11 @@ extern crate libimagstore;
|
||||||
extern crate libimaginteraction;
|
extern crate libimaginteraction;
|
||||||
|
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
|
use resiter::Map;
|
||||||
use clap::App;
|
use clap::App;
|
||||||
|
|
||||||
use libimagerror::trace::MapErrTrace;
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
|
use libimagrt::iter::ReportTouchedResultEntry;
|
||||||
use libimagrt::application::ImagApplication;
|
use libimagrt::application::ImagApplication;
|
||||||
|
|
||||||
mod ui;
|
mod ui;
|
||||||
|
@ -120,7 +121,9 @@ fn set(rt: &Runtime) -> Result<()> {
|
||||||
.map(Ok)
|
.map(Ok)
|
||||||
.into_get_iter(rt.store())
|
.into_get_iter(rt.store())
|
||||||
.map_inner_ok_or_else(|| err_msg("Did not find one entry"))
|
.map_inner_ok_or_else(|| err_msg("Did not find one entry"))
|
||||||
.and_then_ok(|mut e| e.set_category_checked(rt.store(), &name))
|
.and_then_ok(|mut e| e.set_category_checked(rt.store(), &name).map(|_| e))
|
||||||
|
.map_report_touched(&rt)
|
||||||
|
.map_ok(|_| ())
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,9 +135,10 @@ fn get(rt: &Runtime) -> Result<()> {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(Ok)
|
.map(Ok)
|
||||||
.into_get_iter(rt.store())
|
.into_get_iter(rt.store())
|
||||||
.map(|el| el.and_then(|o| o.ok_or_else(|| err_msg("Did not find one entry"))))
|
.map_inner_ok_or_else(|| err_msg("Did not find one entry"))
|
||||||
.map(|entry| entry.and_then(|e| e.get_category()))
|
.map_report_touched(&rt)
|
||||||
.map(|name| name.and_then(|n| writeln!(outlock, "{}", n).map_err(Error::from)))
|
.and_then_ok(|e| e.get_category())
|
||||||
|
.and_then_ok(|n| writeln!(outlock, "{}", n).map_err(Error::from))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,8 +151,8 @@ fn list_category(rt: &Runtime) -> Result<()> {
|
||||||
let mut outlock = out.lock();
|
let mut outlock = out.lock();
|
||||||
|
|
||||||
category
|
category
|
||||||
.get_entries(rt.store())
|
.get_entries(rt.store())?
|
||||||
.map_err_trace_exit_unwrap()
|
.map_report_touched(&rt)
|
||||||
.map(|entry| writeln!(outlock, "{}", entry?.get_location()).map_err(Error::from))
|
.map(|entry| writeln!(outlock, "{}", entry?.get_location()).map_err(Error::from))
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
|
@ -159,7 +163,9 @@ fn list_category(rt: &Runtime) -> Result<()> {
|
||||||
fn create_category(rt: &Runtime) -> Result<()> {
|
fn create_category(rt: &Runtime) -> Result<()> {
|
||||||
let scmd = rt.cli().subcommand_matches("create-category").unwrap(); // safed by main()
|
let scmd = rt.cli().subcommand_matches("create-category").unwrap(); // safed by main()
|
||||||
let name = scmd.value_of("create-category-name").map(String::from).unwrap(); // safed by clap
|
let name = scmd.value_of("create-category-name").map(String::from).unwrap(); // safed by clap
|
||||||
rt.store().create_category(&name).map(|_| ())
|
rt.store()
|
||||||
|
.create_category(&name)
|
||||||
|
.and_then(|e| rt.report_touched(e.get_location()).map_err(Error::from))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delete_category(rt: &Runtime) -> Result<()> {
|
fn delete_category(rt: &Runtime) -> Result<()> {
|
||||||
|
@ -175,7 +181,7 @@ fn delete_category(rt: &Runtime) -> Result<()> {
|
||||||
|
|
||||||
if answer {
|
if answer {
|
||||||
info!("Deleting category '{}'", name);
|
info!("Deleting category '{}'", name);
|
||||||
rt.store().delete_category(&name).map(|_| ())
|
rt.store().delete_category(&name)
|
||||||
} else {
|
} else {
|
||||||
info!("Not doing anything");
|
info!("Not doing anything");
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -188,7 +194,7 @@ fn list_categories(rt: &Runtime) -> Result<()> {
|
||||||
|
|
||||||
rt.store()
|
rt.store()
|
||||||
.all_category_names()?
|
.all_category_names()?
|
||||||
.map(|name| name.and_then(|n| writeln!(outlock, "{}", n).map_err(Error::from)))
|
.and_then_ok(|n| writeln!(outlock, "{}", n).map_err(Error::from))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ use clap::App;
|
||||||
|
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::application::ImagApplication;
|
use libimagrt::application::ImagApplication;
|
||||||
|
use libimagrt::iter::ReportTouchedResultEntry;
|
||||||
use libimagstore::iter::create::StoreIdCreateIteratorExtension;
|
use libimagstore::iter::create::StoreIdCreateIteratorExtension;
|
||||||
use libimagstore::iter::retrieve::StoreIdRetrieveIteratorExtension;
|
use libimagstore::iter::retrieve::StoreIdRetrieveIteratorExtension;
|
||||||
|
|
||||||
|
@ -65,9 +66,9 @@ impl ImagApplication for ImagCreate {
|
||||||
.map(Ok);
|
.map(Ok);
|
||||||
|
|
||||||
if force {
|
if force {
|
||||||
ids.into_retrieve_iter(rt.store()).collect::<Result<Vec<_>>>()
|
ids.into_retrieve_iter(rt.store()).map_report_touched(&rt).collect::<Result<Vec<_>>>()
|
||||||
} else {
|
} else {
|
||||||
ids.into_create_iter(rt.store()).collect::<Result<Vec<_>>>()
|
ids.into_create_iter(rt.store()).map_report_touched(&rt).collect::<Result<Vec<_>>>()
|
||||||
}.map(|_| ())
|
}.map(|_| ())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ use libimagentryedit::edit::Edit;
|
||||||
use libimagentryedit::edit::EditHeader;
|
use libimagentryedit::edit::EditHeader;
|
||||||
use libimagrt::runtime::Runtime;
|
use libimagrt::runtime::Runtime;
|
||||||
use libimagrt::application::ImagApplication;
|
use libimagrt::application::ImagApplication;
|
||||||
|
use libimagrt::iter::ReportTouchedResultEntry;
|
||||||
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
use libimagstore::iter::get::StoreIdGetIteratorExtension;
|
||||||
|
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
|
@ -76,6 +77,7 @@ impl ImagApplication for ImagEdit {
|
||||||
.into_get_iter(rt.store())
|
.into_get_iter(rt.store())
|
||||||
.map_inner_ok_or_else(|| err_msg("Did not find one entry"))
|
.map_inner_ok_or_else(|| err_msg("Did not find one entry"))
|
||||||
.inspect(|e| debug!("Editing = {:?}", e))
|
.inspect(|e| debug!("Editing = {:?}", e))
|
||||||
|
.map_report_touched(&rt)
|
||||||
.and_then_ok(|mut entry| {
|
.and_then_ok(|mut entry| {
|
||||||
if edit_header {
|
if edit_header {
|
||||||
entry.edit_header_and_content(&rt)
|
entry.edit_header_and_content(&rt)
|
||||||
|
|
|
@ -95,6 +95,7 @@ impl ImagApplication for ImagGrep {
|
||||||
.and_then_ok(|entry| {
|
.and_then_ok(|entry| {
|
||||||
if pattern.is_match(entry.get_content()) {
|
if pattern.is_match(entry.get_content()) {
|
||||||
debug!("Matched: {}", entry.get_location());
|
debug!("Matched: {}", entry.get_location());
|
||||||
|
rt.report_touched(entry.get_location())?;
|
||||||
show(&rt, &entry, &pattern, &opts, &mut count)
|
show(&rt, &entry, &pattern, &opts, &mut count)
|
||||||
} else {
|
} else {
|
||||||
debug!("Not matched: {}", entry.get_location());
|
debug!("Not matched: {}", entry.get_location());
|
||||||
|
|
Loading…
Reference in a new issue