summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2018-10-04 18:39:47 +0200
committerMatthias Beyer <mail@beyermatthias.de>2018-11-06 20:33:30 +0100
commit1e6d58bf4c7988b0214406c4ffa4dfdc1eba4a8e (patch)
treeef3d761ea93360391a6eedd8dbc81d597d489111
parentd3400167dfe9e5cb5a146c24e99b901a622a38bf (diff)
downloadimag-1e6d58bf4c7988b0214406c4ffa4dfdc1eba4a8e.tar.gz
imag-1e6d58bf4c7988b0214406c4ffa4dfdc1eba4a8e.tar.xz
-rw-r--r--bin/core/imag-view/src/main.rs42
1 files changed, 18 insertions, 24 deletions
diff --git a/bin/core/imag-view/src/main.rs b/bin/core/imag-view/src/main.rs
index fdcedf6d..859e5af5 100644
--- a/bin/core/imag-view/src/main.rs
+++ b/bin/core/imag-view/src/main.rs
@@ -58,7 +58,6 @@ use failure::Error;
use failure::err_msg;
use libimagrt::setup::generate_runtime_setup;
-use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
use libimagerror::iter::TraceIterator;
use libimagerror::io::ToExitCode;
@@ -66,8 +65,6 @@ use libimagerror::exit::ExitUnwrap;
use libimagentryview::builtin::stdout::StdoutViewer;
use libimagentryview::builtin::md::MarkdownViewer;
use libimagentryview::viewer::Viewer;
-use libimagstore::storeid::IntoStoreId;
-use libimagstore::storeid::StoreIdIterator;
use libimagstore::iter::get::StoreIdGetIteratorExtension;
use libimagstore::store::FileLockEntry;
@@ -83,27 +80,26 @@ fn main() {
let view_header = rt.cli().is_present("view-header");
let hide_content = rt.cli().is_present("not-view-content");
- let entry_ids = rt.ids::<::ui::PathProvider>()
+ let entries = rt.ids::<::ui::PathProvider>()
.map_err_trace_exit_unwrap(1)
.into_iter()
- .map(|x| Ok(x) as Result<_, StoreError>)
+ .map(Ok)
.into_get_iter(rt.store())
.trace_unwrap_exit(1)
.map(|e| {
- e.ok_or_else(|| String::from("Entry not found"))
- .map_err(StoreError::from)
+ e.ok_or_else(|| err_msg("Entry not found"))
+ .map_err(Error::from)
.map_err_trace_exit_unwrap(1)
});
if rt.cli().is_present("in") {
- let files = entry_ids
- .into_get_iter(rt.store())
- .trace_unwrap_exit(1)
- .map(|e| {
- e.ok_or_else(|| err_msg("Entry not found"))
- .map_err_trace_exit_unwrap(1)
+ let files = entries
+ .map(|entry| {
+ let tmpfile = create_tempfile_for(&entry, view_header, hide_content);
+ rt.report_touched(entry.get_location())
+ .map_err_trace_exit_unwrap(1);
+ tmpfile
})
- .map(|entry| create_tempfile_for(&entry, view_header, hide_content))
.collect::<Vec<_>>();
let mut command = {
@@ -178,14 +174,6 @@ fn main() {
drop(files);
} else {
- let iter = entry_ids
- .into_get_iter(rt.store())
- .map(|e| {
- e.map_err_trace_exit_unwrap(1)
- .ok_or_else(|| err_msg("Entry not found"))
- .map_err_trace_exit_unwrap(1)
- });
-
let out = rt.stdout();
let mut outlock = out.lock();
@@ -206,7 +194,7 @@ fn main() {
let viewer = MarkdownViewer::new(&rt);
let seperator = basesep.map(|s| build_seperator(s, sep_width));
- entry_ids
+ entries
.enumerate()
.for_each(|(n, entry)| {
if n != 0 {
@@ -218,6 +206,9 @@ fn main() {
viewer
.view_entry(&entry, &mut outlock)
.map_err_trace_exit_unwrap(1);
+
+ rt.report_touched(entry.get_location())
+ .map_err_trace_exit_unwrap(1);
});
} else {
let mut viewer = StdoutViewer::new(view_header, !hide_content);
@@ -238,7 +229,7 @@ fn main() {
}
let seperator = basesep.map(|s| build_seperator(s, sep_width));
- entry_ids
+ entries
.enumerate()
.for_each(|(n, entry)| {
if n != 0 {
@@ -250,6 +241,9 @@ fn main() {
viewer
.view_entry(&entry, &mut outlock)
.map_err_trace_exit_unwrap(1);
+
+ rt.report_touched(entry.get_location())
+ .map_err_trace_exit_unwrap(1);
});
}
}