summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-05-01 17:42:47 +0200
committerMatthias Beyer <mail@beyermatthias.de>2018-05-01 17:44:05 +0200
commit829e425c12a5460aa01e5444642bd12e6e987499 (patch)
tree1906b779f34bc0bffcbb55a18dc4c7d0613b67f8 /bin
parenta9d0f3d53a3219c7b0d13582b4afc7e4f332d63c (diff)
Refactor imag-view to new store iterator interface
Diffstat (limited to 'bin')
-rw-r--r--bin/core/imag-view/src/main.rs29
1 files changed, 13 insertions, 16 deletions
diff --git a/bin/core/imag-view/src/main.rs b/bin/core/imag-view/src/main.rs
index 5cafb007..bef7e2bc 100644
--- a/bin/core/imag-view/src/main.rs
+++ b/bin/core/imag-view/src/main.rs
@@ -68,10 +68,10 @@ use libimagentryview::builtin::md::MarkdownViewer;
use libimagentryview::viewer::Viewer;
use libimagentryview::error::ViewError as VE;
use libimagstore::storeid::IntoStoreId;
+use libimagstore::storeid::StoreIdIterator;
use libimagstore::error::StoreError;
use libimagstore::iter::get::StoreIdGetIteratorExtension;
use libimagstore::store::FileLockEntry;
-use libimagstore::storeid::StoreId;
mod ui;
use ui::build_ui;
@@ -89,11 +89,10 @@ fn main() {
if rt.cli().is_present("in") {
let files = entry_ids
- .into_iter()
.into_get_iter(rt.store())
+ .trace_unwrap_exit(1)
.map(|e| {
- e.map_err_trace_exit_unwrap(1)
- .ok_or_else(|| String::from("Entry not found"))
+ e.ok_or_else(|| String::from("Entry not found"))
.map_err(StoreError::from)
.map_err_trace_exit_unwrap(1)
})
@@ -175,7 +174,6 @@ fn main() {
drop(files);
} else {
let iter = entry_ids
- .into_iter()
.into_get_iter(rt.store())
.map(|e| {
e.map_err_trace_exit_unwrap(1)
@@ -249,13 +247,13 @@ fn main() {
}
}
-fn entry_ids(rt: &Runtime) -> Vec<StoreId> {
+fn entry_ids(rt: &Runtime) -> StoreIdIterator {
match rt.cli().values_of("id") {
- Some(pathes) => pathes
- .map(PathBuf::from)
- .map(PathBuf::into_storeid)
- .trace_unwrap_exit(1)
- .collect(),
+ Some(p) => {
+ let pathes : Vec<String> = p.map(String::from).collect();
+ let iter = pathes.into_iter().map(PathBuf::from).map(PathBuf::into_storeid);
+ StoreIdIterator::new(Box::new(iter))
+ },
None => if rt.cli().is_present("entries-from-stdin") {
let stdin = rt.stdin().unwrap_or_else(|| {
@@ -269,11 +267,10 @@ fn entry_ids(rt: &Runtime) -> Vec<StoreId> {
::std::process::exit(1)
});
- buf.lines()
- .map(PathBuf::from)
- .map(PathBuf::into_storeid)
- .trace_unwrap_exit(1)
- .collect()
+ let lines : Vec<String> = buf.lines().map(String::from).collect();
+ let iter = lines.into_iter().map(PathBuf::from).map(PathBuf::into_storeid);
+
+ StoreIdIterator::new(Box::new(iter))
} else {
error!("Something weird happened. I was not able to find the path of the entries to edit");
::std::process::exit(1)