summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-02-05 01:37:32 +0100
committerMatthias Beyer <mail@beyermatthias.de>2019-02-11 03:52:04 +0100
commit90eaeb642af712c6dc556ad8342e6d218c892cc1 (patch)
tree54764c60307db0bd7dd43c7c6fa222f98be545dd
parent01fa19aadebbe94c6b759608e2f75f2714b74c94 (diff)
downloadimag-90eaeb642af712c6dc556ad8342e6d218c892cc1.zip
imag-90eaeb642af712c6dc556ad8342e6d218c892cc1.tar.gz
Remove magic constants in trace_unwrap_exit/map_err_trace_exit_unwrap calls
This patch removes the magic constant we used when calling `trace_unwrap_exit()` or `map_err_trace_exit_unwrap()`. We used to call it with `1` as parameter, where the number was the exit code to use. Now the implementation of the function does it automatically (using 1 (one) as exit code). All calls of these functions were fixed. Thanks to vim this was easy. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r--bin/core/imag-annotate/src/main.rs48
-rw-r--r--bin/core/imag-annotate/src/ui.rs6
-rw-r--r--bin/core/imag-category/src/main.rs30
-rw-r--r--bin/core/imag-category/src/ui.rs4
-rw-r--r--bin/core/imag-diagnostics/src/main.rs16
-rw-r--r--bin/core/imag-edit/src/main.rs10
-rw-r--r--bin/core/imag-edit/src/ui.rs2
-rw-r--r--bin/core/imag-gps/src/main.rs24
-rw-r--r--bin/core/imag-gps/src/ui.rs6
-rw-r--r--bin/core/imag-grep/src/main.rs4
-rw-r--r--bin/core/imag-ids/src/id_filters.rs2
-rw-r--r--bin/core/imag-ids/src/main.rs12
-rw-r--r--bin/core/imag-link/src/main.rs40
-rw-r--r--bin/core/imag-link/src/ui.rs9
-rw-r--r--bin/core/imag-mv/src/main.rs20
-rw-r--r--bin/core/imag-ref/src/main.rs17
-rw-r--r--bin/core/imag-store/src/create.rs5
-rw-r--r--bin/core/imag-store/src/delete.rs4
-rw-r--r--bin/core/imag-store/src/get.rs5
-rw-r--r--bin/core/imag-store/src/main.rs2
-rw-r--r--bin/core/imag-store/src/retrieve.rs6
-rw-r--r--bin/core/imag-store/src/update.rs3
-rw-r--r--bin/core/imag-store/src/verify.rs5
-rw-r--r--bin/core/imag-tag/src/main.rs8
-rw-r--r--bin/core/imag-tag/src/ui.rs2
-rw-r--r--bin/core/imag-view/src/main.rs34
-rw-r--r--bin/core/imag-view/src/ui.rs2
-rw-r--r--bin/domain/imag-bookmark/src/main.rs22
-rw-r--r--bin/domain/imag-contact/src/create.rs21
-rw-r--r--bin/domain/imag-contact/src/main.rs42
-rw-r--r--bin/domain/imag-diary/src/create.rs9
-rw-r--r--bin/domain/imag-diary/src/delete.rs7
-rw-r--r--bin/domain/imag-diary/src/list.rs8
-rw-r--r--bin/domain/imag-diary/src/main.rs6
-rw-r--r--bin/domain/imag-diary/src/view.rs7
-rw-r--r--bin/domain/imag-habit/src/main.rs122
-rw-r--r--bin/domain/imag-log/src/main.rs34
-rw-r--r--bin/domain/imag-mail/src/main.rs10
-rw-r--r--bin/domain/imag-notes/src/main.rs18
-rw-r--r--bin/domain/imag-timetrack/src/cont.rs5
-rw-r--r--bin/domain/imag-timetrack/src/day.rs5
-rw-r--r--bin/domain/imag-timetrack/src/list.rs5
-rw-r--r--bin/domain/imag-timetrack/src/main.rs2
-rw-r--r--bin/domain/imag-timetrack/src/month.rs7
-rw-r--r--bin/domain/imag-timetrack/src/start.rs2
-rw-r--r--bin/domain/imag-timetrack/src/stop.rs9
-rw-r--r--bin/domain/imag-timetrack/src/track.rs2
-rw-r--r--bin/domain/imag-timetrack/src/week.rs5
-rw-r--r--bin/domain/imag-timetrack/src/year.rs5
-rw-r--r--bin/domain/imag-todo/src/main.rs6
-rw-r--r--bin/domain/imag-wiki/src/main.rs38
-rw-r--r--lib/core/libimagerror/src/iter.rs10
-rw-r--r--lib/core/libimagerror/src/trace.rs6
53 files changed, 377 insertions, 362 deletions
diff --git a/bin/core/imag-annotate/src/main.rs b/bin/core/imag-annotate/src/main.rs
index afb5ce6..c764758 100644
--- a/bin/core/imag-annotate/src/main.rs
+++ b/bin/core/imag-annotate/src/main.rs
@@ -87,7 +87,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-annotation", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -97,27 +97,27 @@ fn main() {
fn add(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("add").unwrap(); // safed by main()
- let mut ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1).into_iter();
+ let mut ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap().into_iter();
if let Some(first) = ids.next() {
let mut annotation = rt.store()
.get(first.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| EM::EntryNotFound(first.local_display_string()))
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.annotate(rt.store())
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
- let _ = annotation.edit_content(&rt).map_err_trace_exit_unwrap(1);
+ let _ = annotation.edit_content(&rt).map_err_trace_exit_unwrap();
for id in ids {
let mut entry = rt.store().get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| format_err!("Not found: {}", id.local_display_string()))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
- let _ = entry.add_internal_link(&mut annotation).map_err_trace_exit_unwrap(1);
+ let _ = entry.add_internal_link(&mut annotation).map_err_trace_exit_unwrap();
}
if !scmd.is_present("dont-print-name") {
@@ -125,7 +125,7 @@ fn add(rt: &Runtime) {
.get_header()
.read_string("annotation.name")
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
{
let _ = writeln!(rt.stdout(), "Name of the annotation: {}", annotation_id)
.to_exit_code()
@@ -144,19 +144,19 @@ fn remove(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("remove").unwrap(); // safed by main()
let annotation_name = scmd.value_of("annotation_name").unwrap(); // safed by clap
let delete = scmd.is_present("delete-annotation");
- let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1);
+ let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
ids.into_iter().for_each(|id| {
let mut entry = rt.store()
.get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| EM::EntryNotFound(id.local_display_string()))
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let annotation = entry
.denotate(rt.store(), annotation_name)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
if delete {
debug!("Deleting annotation object");
@@ -167,7 +167,7 @@ fn remove(rt: &Runtime) {
let _ = rt
.store()
.delete(loc)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
} else {
warn!("Not having annotation object, cannot delete!");
}
@@ -181,7 +181,7 @@ fn remove(rt: &Runtime) {
fn list(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("list").unwrap(); // safed by clap
let with_text = scmd.is_present("list-with-text");
- let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1);
+ let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
if ids.len() != 0 {
let _ = ids
@@ -190,16 +190,16 @@ fn list(rt: &Runtime) {
let _ = rt
.store()
.get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| EM::EntryNotFound(id.local_display_string()))
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.annotations()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|opt| opt.ok_or_else(|| format_err!("Cannot find entry")))
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.enumerate()
.for_each(|(i, entry)| list_annotation(&rt, i, entry, with_text));
});
@@ -207,11 +207,11 @@ fn list(rt: &Runtime) {
// show them all
rt.store()
.all_annotations()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|opt| opt.ok_or_else(|| format_err!("Cannot find entry")))
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.enumerate()
.for_each(|(i, entry)| list_annotation(&rt, i, entry, with_text));
}
diff --git a/bin/core/imag-annotate/src/ui.rs b/bin/core/imag-annotate/src/ui.rs
index 024d6a3..72074c0 100644
--- a/bin/core/imag-annotate/src/ui.rs
+++ b/bin/core/imag-annotate/src/ui.rs
@@ -110,7 +110,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
("remove", Some(subm)) => {
@@ -124,7 +124,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
("list", Some(subm)) => {
@@ -138,7 +138,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
(other, _) => {
diff --git a/bin/core/imag-category/src/main.rs b/bin/core/imag-category/src/main.rs
index 2a6e8a1..96882e4 100644
--- a/bin/core/imag-category/src/main.rs
+++ b/bin/core/imag-category/src/main.rs
@@ -81,7 +81,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-category", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -92,11 +92,11 @@ fn main() {
fn set(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("set").unwrap(); // safed by main()
let name = scmd.value_of("set-name").map(String::from).unwrap(); // safed by clap
- let sids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1);
+ let sids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
StoreIdIterator::new(Box::new(sids.into_iter().map(Ok)))
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|o| o.unwrap_or_else(|| {
error!("Did not find one entry");
::std::process::exit(1)
@@ -104,23 +104,23 @@ fn set(rt: &Runtime) {
.for_each(|mut entry| {
let _ = entry
.set_category_checked(rt.store(), &name)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
})
}
fn get(rt: &Runtime) {
- let sids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1);
+ let sids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
let out = rt.stdout();
let mut outlock = out.lock();
StoreIdIterator::new(Box::new(sids.into_iter().map(Ok)))
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|o| o.unwrap_or_else(|| {
error!("Did not find one entry");
::std::process::exit(1)
}))
- .map(|entry| entry.get_category().map_err_trace_exit_unwrap(1))
+ .map(|entry| entry.get_category().map_err_trace_exit_unwrap())
.for_each(|name| {
let _ = writeln!(outlock, "{}", name).to_exit_code().unwrap_or_exit();
})
@@ -130,15 +130,15 @@ fn list_category(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("list-category").unwrap(); // safed by main()
let name = scmd.value_of("list-category-name").map(String::from).unwrap(); // safed by clap
- if let Some(category) = rt.store().get_category_by_name(&name).map_err_trace_exit_unwrap(1) {
+ if let Some(category) = rt.store().get_category_by_name(&name).map_err_trace_exit_unwrap() {
let out = rt.stdout();
let mut outlock = out.lock();
category
.get_entries(rt.store())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.for_each(|entry| {
- writeln!(outlock, "{}", entry.map_err_trace_exit_unwrap(1).get_location())
+ writeln!(outlock, "{}", entry.map_err_trace_exit_unwrap().get_location())
.to_exit_code()
.unwrap_or_exit();
})
@@ -155,7 +155,7 @@ fn create_category(rt: &Runtime) {
let _ = rt
.store()
.create_category(&name)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
fn delete_category(rt: &Runtime) {
@@ -170,14 +170,14 @@ fn delete_category(rt: &Runtime) {
::std::process::exit(1)
});
let mut output = rt.stdout();
- let answer = ask_bool(&ques, Some(false), &mut input, &mut output).map_err_trace_exit_unwrap(1);
+ let answer = ask_bool(&ques, Some(false), &mut input, &mut output).map_err_trace_exit_unwrap();
if answer {
info!("Deleting category '{}'", name);
let _ = rt
.store()
.delete_category(&name)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
} else {
info!("Not doing anything");
}
@@ -189,9 +189,9 @@ fn list_categories(rt: &Runtime) {
rt.store()
.all_category_names()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.for_each(|name| {
- writeln!(outlock, "{}", name.map_err_trace_exit_unwrap(1))
+ writeln!(outlock, "{}", name.map_err_trace_exit_unwrap())
.to_exit_code()
.unwrap_or_exit();
})
diff --git a/bin/core/imag-category/src/ui.rs b/bin/core/imag-category/src/ui.rs
index a9b50bf..fca41bd 100644
--- a/bin/core/imag-category/src/ui.rs
+++ b/bin/core/imag-category/src/ui.rs
@@ -136,7 +136,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
("get", Some(subm)) => {
@@ -150,7 +150,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
(other, _) => {
diff --git a/bin/core/imag-diagnostics/src/main.rs b/bin/core/imag-diagnostics/src/main.rs
index 47b48b7..257af6a 100644
--- a/bin/core/imag-diagnostics/src/main.rs
+++ b/bin/core/imag-diagnostics/src/main.rs
@@ -143,12 +143,12 @@ fn main() {
let diags = rt.store()
.entries()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter()
.map(|e| {
- e.map_err_trace_exit_unwrap(1)
+ e.map_err_trace_exit_unwrap()
.ok_or_else(|| Error::from(err_msg("Unable to get entry".to_owned())))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
})
.map(|e| {
let diag = Diagnostic::for_entry(&e);
@@ -162,14 +162,14 @@ fn main() {
// The store has an API for it, but the cache size calculation is O(n) and we can do
// better by simply flushing the cache each 100 entries
if entries_counter > 100 {
- let _ = rt.store().flush_cache().map_err_trace_exit_unwrap(1);
+ let _ = rt.store().flush_cache().map_err_trace_exit_unwrap();
entries_counter = 0;
}
diag
})
.collect::<Result<Vec<_>>>()
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
spinner.finish();
let n = diags.len();
@@ -244,7 +244,7 @@ fn main() {
num,
path
.into_pathbuf()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.to_str()
.unwrap_or("Failed converting path to string")
);
@@ -257,7 +257,7 @@ fn main() {
num,
path
.into_pathbuf()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.to_str()
.unwrap_or("Failed converting path to string")
);
@@ -271,7 +271,7 @@ fn get_config(rt: &Runtime, s: &'static str) -> Option<String> {
rt.config().and_then(|cfg| {
cfg.read(s)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|opt| match opt {
&Value::String(ref s) => s.to_owned(),
_ => {
diff --git a/bin/core/imag-edit/src/main.rs b/bin/core/imag-edit/src/main.rs
index 9eb53cf..c0a97dd 100644
--- a/bin/core/imag-edit/src/main.rs
+++ b/bin/core/imag-edit/src/main.rs
@@ -63,11 +63,11 @@ fn main() {
let edit_header = rt.cli().is_present("edit-header");
let edit_header_only = rt.cli().is_present("edit-header-only");
- let sids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1);
+ let sids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
StoreIdIterator::new(Box::new(sids.into_iter().map(Ok)))
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|o| o.unwrap_or_else(|| {
error!("Did not find one entry");
::std::process::exit(1)
@@ -76,15 +76,15 @@ fn main() {
if edit_header {
let _ = entry
.edit_header_and_content(&rt)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
} else if edit_header_only {
let _ = entry
.edit_header(&rt)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
} else {
let _ = entry
.edit_content(&rt)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
});
}
diff --git a/bin/core/imag-edit/src/ui.rs b/bin/core/imag-edit/src/ui.rs
index 2b95a84..3b78825 100644
--- a/bin/core/imag-edit/src/ui.rs
+++ b/bin/core/imag-edit/src/ui.rs
@@ -66,6 +66,6 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
}
}
diff --git a/bin/core/imag-gps/src/main.rs b/bin/core/imag-gps/src/main.rs
index ac67306..6ca785d 100644
--- a/bin/core/imag-gps/src/main.rs
+++ b/bin/core/imag-gps/src/main.rs
@@ -79,7 +79,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-gps", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
}
@@ -96,7 +96,7 @@ fn add(rt: &Runtime) {
.map(FromStr::from_str)
.map(|elem| {
elem.or_else(|_| Err(Error::from(err_msg("Error while converting number"))))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
})
.collect::<Vec<i64>>();
@@ -125,18 +125,18 @@ fn add(rt: &Runtime) {
};
rt.ids::<::ui::PathProvider>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_iter()
.for_each(|id| {
rt.store()
.get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| { // if we have Ok(None)
error!("No such entry: {}", id);
exit(1)
})
.set_coordinates(c.clone())
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(&id).unwrap_or_exit();
});
@@ -150,24 +150,24 @@ fn remove(rt: &Runtime) {
.is_present("print-removed"); // safed by main()
rt.ids::<::ui::PathProvider>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_iter()
.for_each(|id| {
let removed_value = rt
.store()
.get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| { // if we have Ok(None)
error!("No such entry: {}", id);
exit(1)
})
.remove_coordinates()
- .map_err_trace_exit_unwrap(1) // The delete action failed
+ .map_err_trace_exit_unwrap() // The delete action failed
.unwrap_or_else(|| { // if we have Ok(None)
error!("Entry had no coordinates: {}", id);
exit(1)
})
- .map_err_trace_exit_unwrap(1); // The parsing of the deleted values failed
+ .map_err_trace_exit_unwrap(); // The parsing of the deleted values failed
if print_removed {
let _ = writeln!(rt.stdout(), "{}", removed_value).to_exit_code().unwrap_or_exit();
@@ -180,19 +180,19 @@ fn remove(rt: &Runtime) {
fn get(rt: &Runtime) {
let mut stdout = rt.stdout();
rt.ids::<::ui::PathProvider>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_iter()
.for_each(|id| {
let value = rt
.store()
.get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| { // if we have Ok(None)
error!("No such entry: {}", id);
exit(1)
})
.get_coordinates()
- .map_err_trace_exit_unwrap(1) // The get action failed
+ .map_err_trace_exit_unwrap() // The get action failed
.unwrap_or_else(|| { // if we have Ok(None)
error!("Entry has no coordinates: {}", id);
exit(1)
diff --git a/bin/core/imag-gps/src/ui.rs b/bin/core/imag-gps/src/ui.rs
index 878daf6..572e1c4 100644
--- a/bin/core/imag-gps/src/ui.rs
+++ b/bin/core/imag-gps/src/ui.rs
@@ -112,7 +112,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
("remove", Some(subm)) => {
@@ -126,7 +126,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
("get", Some(subm)) => {
@@ -140,7 +140,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
},
(other, _) => {
diff --git a/bin/core/imag-grep/src/main.rs b/bin/core/imag-grep/src/main.rs
index 9ab3c29..faf5c13 100644
--- a/bin/core/imag-grep/src/main.rs
+++ b/bin/core/imag-grep/src/main.rs
@@ -87,9 +87,9 @@ fn main() {
let overall_count = rt
.store()
.entries()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter()
- .filter_map(|res| res.map_err_trace_exit_unwrap(1))
+ .filter_map(|res| res.map_err_trace_exit_unwrap())
.filter(|entry| pattern.is_match(entry.get_content()))
.map(|entry| show(&rt, &entry, &pattern, &opts, &mut count))
.count();
diff --git a/bin/core/imag-ids/src/id_filters.rs b/bin/core/imag-ids/src/id_filters.rs
index 84a66b0..da9de96 100644
--- a/bin/core/imag-ids/src/id_filters.rs
+++ b/bin/core/imag-ids/src/id_filters.rs
@@ -405,7 +405,7 @@ pub mod header_filter_lang {
.get_header()
.read(selector_str)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|value| {
let comp = Comparator(&self.compare_operator, &self.compare_value);
let val = match self.selector.function() {
diff --git a/bin/core/imag-ids/src/main.rs b/bin/core/imag-ids/src/main.rs
index 2985b13..72c07b6 100644
--- a/bin/core/imag-ids/src/main.rs
+++ b/bin/core/imag-ids/src/main.rs
@@ -93,14 +93,14 @@ fn main() {
let iterator = if rt.ids_from_stdin() {
debug!("Fetching IDs from stdin...");
- let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1);
+ let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
Box::new(ids.into_iter().map(Ok))
as Box<Iterator<Item = Result<StoreId, _>>>
} else {
- Box::new(rt.store().entries().map_err_trace_exit_unwrap(1))
+ Box::new(rt.store().entries().map_err_trace_exit_unwrap())
as Box<Iterator<Item = Result<StoreId, _>>>
}
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.filter(|id| collection_filter.filter(id))
.filter(|id| match query_filter.as_ref() {
None => true,
@@ -108,7 +108,7 @@ fn main() {
let entry = rt
.store()
.get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("Tried to get '{}', but it does not exist!", id);
exit(1)
@@ -127,10 +127,10 @@ fn main() {
trace!("Got output: {:?}", stdout);
iterator.for_each(|id| {
- let _ = rt.report_touched(&id).unwrap_or_exit(); // .map_err_trace_exit_unwrap(1);
+ let _ = rt.report_touched(&id).unwrap_or_exit(); // .map_err_trace_exit_unwrap();
if !rt.output_is_pipe() {
- let id = id.to_str().map_err_trace_exit_unwrap(1);
+ let id = id.to_str().map_err_trace_exit_unwrap();
trace!("Writing to {:?}", stdout);
writeln!(stdout, "{}", id)
.to_exit_code()
diff --git a/bin/core/imag-link/src/main.rs b/bin/core/imag-link/src/main.rs
index 79f70a4..dc9be71 100644
--- a/bin/core/imag-link/src/main.rs
+++ b/bin/core/imag-link/src/main.rs
@@ -111,7 +111,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-link", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -125,7 +125,7 @@ fn main() {
}
})
.ok_or_else(|| Error::from(err_msg("No commandline call".to_owned())))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockEntry<'a>>> {
@@ -142,7 +142,7 @@ fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockE
fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I)
where I: Iterator<Item = &'a str>
{
- let mut from_entry = match get_entry_by_name(rt, from).map_err_trace_exit_unwrap(1) {
+ let mut from_entry = match get_entry_by_name(rt, from).map_err_trace_exit_unwrap() {
Some(e) => e,
None => {
debug!("No 'from' entry");
@@ -152,7 +152,7 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I)
for entry in to {
debug!("Handling 'to' entry: {:?}", entry);
- if !rt.store().get(PathBuf::from(entry)).map_err_trace_exit_unwrap(1).is_some() {
+ if !rt.store().get(PathBuf::from(entry)).map_err_trace_exit_unwrap().is_some() {
debug!("Linking externally: {:?} -> {:?}", from, entry);
let url = Url::parse(entry).unwrap_or_else(|e| {
error!("Error parsing URL: {:?}", e);
@@ -161,22 +161,22 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I)
let iter = from_entry
.add_external_link(rt.store(), url)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_iter();
let _ = rt.report_all_touched(iter).unwrap_or_exit();
} else {
debug!("Linking internally: {:?} -> {:?}", from, entry);
- let from_id = StoreId::new_baseless(PathBuf::from(from)).map_err_trace_exit_unwrap(1);
- let entr_id = StoreId::new_baseless(PathBuf::from(entry)).map_err_trace_exit_unwrap(1);
+ let from_id = StoreId::new_baseless(PathBuf::from(from)).map_err_trace_exit_unwrap();
+ let entr_id = StoreId::new_baseless(PathBuf::from(entry)).map_err_trace_exit_unwrap();
if from_id == entr_id {
error!("Cannot link entry with itself. Exiting");
::std::process::exit(1)
}
- let mut to_entry = match rt.store().get(entr_id).map_err_trace_exit_unwrap(1) {
+ let mut to_entry = match rt.store().get(entr_id).map_err_trace_exit_unwrap() {
Some(e) => e,
None => {
warn!("No 'to' entry: {}", entry);
@@ -185,7 +185,7 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I)
};
let _ = from_entry
.add_internal_link(&mut to_entry)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(to_entry.get_location()).unwrap_or_exit();
}
@@ -206,21 +206,21 @@ fn remove_linking(rt: &Runtime) {
.map(|id| {
rt.store()
.get(id)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| warn_exit("No 'from' entry", 1))
.unwrap() // safe by line above
})
.unwrap();
rt.ids::<::ui::PathProvider>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_iter()
.for_each(|id| match rt.store().get(id.clone()) {
Err(e) => trace_error(&e),
Ok(Some(mut to_entry)) => {
let _ = to_entry
.remove_internal_link(&mut from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(to_entry.get_location()).unwrap_or_exit();
},
@@ -236,7 +236,7 @@ fn remove_linking(rt: &Runtime) {
error!("Error parsing URL: {:?}", e);
::std::process::exit(1);
});
- from.remove_external_link(rt.store(), url).map_err_trace_exit_unwrap(1);
+ from.remove_external_link(rt.store(), url).map_err_trace_exit_unwrap();
info!("Ok: {}", id);
} else {
warn!("Entry not found: {:?}", id);
@@ -248,16 +248,16 @@ fn remove_linking(rt: &Runtime) {
}
fn unlink(rt: &Runtime) {
- rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1).into_iter().for_each(|id| {
+ rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap().into_iter().for_each(|id| {
rt.store()
.get(id.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
warn!("No entry for {}", id);
::std::process::exit(1)
})
.unlink(rt.store())
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(&id).unwrap_or_exit();
});
@@ -274,10 +274,10 @@ fn list_linkings(rt: &Runtime) {
let mut tab = ::prettytable::Table::new();
tab.set_titles(row!["#", "Link"]);
- rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1).into_iter().for_each(|id| {
+ rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap().into_iter().for_each(|id| {
match rt.store().get(id.clone()) {
Ok(Some(entry)) => {
- for (i, link) in entry.get_internal_links().map_err_trace_exit_unwrap(1).enumerate() {
+ for (i, link) in entry.get_internal_links().map_err_trace_exit_unwrap().enumerate() {
let link = link
.to_str()
.map_warn_err(|e| format!("Failed to convert StoreId to string: {:?}", e))
@@ -296,11 +296,11 @@ fn list_linkings(rt: &Runtime) {
if list_externals {
entry.get_external_links(rt.store())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.enumerate()
.for_each(|(i, link)| {
let link = link
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_string();
if list_plain {
diff --git a/bin/core/imag-link/src/ui.rs b/bin/core/imag-link/src/ui.rs
index 3b93636..48988ad 100644
--- a/bin/core/imag-link/src/ui.rs
+++ b/bin/core/imag-link/src/ui.rs
@@ -26,7 +26,6 @@ use libimagstore::storeid::IntoStoreId;
use libimagrt::runtime::IdPathProvider;
use libimagerror::trace::MapErrTrace;
-
pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
app
.subcommand(SubCommand::with_name("remove")
@@ -131,7 +130,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
Some(to)
},
@@ -147,7 +146,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
Some(ids)
},
@@ -164,7 +163,7 @@ impl IdPathProvider for PathProvider {
.map(PathBuf::from)
.map(|pb| pb.into_storeid())
.collect::<Result<Vec<_>, _>>()
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
Some(ids)
},
@@ -175,7 +174,7 @@ impl IdPathProvider for PathProvider {
ids.unwrap_or_else(|| {
matches.values_of("to")
.unwrap()
- .map(|s| PathBuf::from(s).into_storeid().map_err_trace_exit_unwrap(1))
+ .map(|s| PathBuf::from(s).into_storeid().map_err_trace_exit_unwrap())
.collect()
})
}
diff --git a/bin/core/imag-mv/src/main.rs b/bin/core/imag-mv/src/main.rs
index 118f609..ff26706 100644
--- a/bin/core/imag-mv/src/main.rs
+++ b/bin/core/imag-mv/src/main.rs
@@ -74,7 +74,7 @@ fn main() {
.map(PathBuf::from)
.map(StoreId::new_baseless)
.unwrap() // unwrap safe by clap
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let destname = rt
.cli()
@@ -82,22 +82,22 @@ fn main() {
.map(PathBuf::from)
.map(StoreId::new_baseless)
.unwrap() // unwrap safe by clap
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
// remove links to entry, and re-add them later
let mut linked_entries = {
rt.store()
.get(sourcename.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("Funny things happened: Entry moved to destination did not fail, but entry does not exist");
exit(1)
})
.get_internal_links()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|link| Ok(link.get_store_id().clone()) as Result<_, _>)
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|e| {
e.unwrap_or_else(|| {
error!("Linked entry does not exist");
@@ -111,14 +111,14 @@ fn main() {
let mut entry = rt
.store()
.get(sourcename.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("Source Entry does not exist");
exit(1)
});
for link in linked_entries.iter_mut() {
- let _ = entry.remove_internal_link(link).map_err_trace_exit_unwrap(1);
+ let _ = entry.remove_internal_link(link).map_err_trace_exit_unwrap();
}
}
@@ -130,7 +130,7 @@ fn main() {
relink(rt.store(), sourcename.clone(), &mut linked_entries);
e
})
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(&destname).unwrap_or_exit();
@@ -143,7 +143,7 @@ fn main() {
fn relink<'a>(store: &'a Store, target: StoreId, linked_entries: &mut Vec<FileLockEntry<'a>>) {
let mut entry = store
.get(target)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("Funny things happened: Entry moved to destination did not fail, but entry does not exist");
exit(1)
@@ -151,6 +151,6 @@ fn relink<'a>(store: &'a Store, target: StoreId, linked_entries: &mut Vec<FileLo
for mut link in linked_entries {
- let _ = entry.add_internal_link(&mut link).map_err_trace_exit_unwrap(1);
+ let _ = entry.add_internal_link(&mut link).map_err_trace_exit_unwrap();
}
}
diff --git a/bin/core/imag-ref/src/main.rs b/bin/core/imag-ref/src/main.rs
index ad72cfe..9d8e131 100644
--- a/bin/core/imag-ref/src/main.rs
+++ b/bin/core/imag-ref/src/main.rs
@@ -51,6 +51,7 @@ use std::path::PathBuf;
use std::process::exit;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagrt::setup::generate_runtime_setup;
use libimagrt::runtime::Runtime;
use libimagstore::storeid::IntoStoreId;
@@ -72,7 +73,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-ref", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -87,13 +88,13 @@ fn deref(rt: &Runtime) {
.map(PathBuf::from)
.unwrap() // saved by clap
.into_storeid()
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
- match rt.store().get(id.clone()).map_err_trace_exit_unwrap(1) {
+ match rt.store().get(id.clone()).map_err_trace_exit_unwrap() {
Some(entry) => {
entry
.get_path()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.to_str()
.ok_or_else(|| {
error!("Could not transform path into string!");
@@ -121,7 +122,7 @@ fn remove(rt: &Runtime) {
.map(PathBuf::from)
.unwrap() // saved by clap
.into_storeid()
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let mut input = rt.stdin().unwrap_or_else(|| {
error!("No input stream. Cannot ask for permission");
@@ -130,13 +131,13 @@ fn remove(rt: &Runtime) {
let mut output = rt.stdout();
- match rt.store().get(id.clone()).map_err_trace_exit_unwrap(1) {
+ match rt.store().get(id.clone()).map_err_trace_exit_unwrap() {
Some(mut entry) => {
if yes ||
ask_bool(&format!("Delete ref from entry '{}'", id), None, &mut input, &mut output)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
{
- let _ = entry.remove_ref().map_err_trace_exit_unwrap(1);
+ let _ = entry.remove_ref().map_err_trace_exit_unwrap();
} else {
info!("Aborted");
}
diff --git a/bin/core/imag-store/src/create.rs b/bin/core/imag-store/src/create.rs
index 527a89f..c6830a4 100644
--- a/bin/core/imag-store/src/create.rs
+++ b/bin/core/imag-store/src/create.rs
@@ -32,6 +32,7 @@ use libimagrt::runtime::Runtime;
use libimagstore::store::Entry;
use libimagstore::storeid::StoreId;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagutil::debug_result::*;
use util::build_toml_header;
@@ -44,7 +45,7 @@ pub fn create(rt: &Runtime) {
let path = scmd.value_of("path").unwrap();
let path = PathBuf::from(path);
let store = Some(rt.store().path().clone());
- let path = StoreId::new(store, path).map_err_trace_exit_unwrap(1);
+ let path = StoreId::new(store, path).map_err_trace_exit_unwrap();
debug!("path = {:?}", path);
@@ -61,7 +62,7 @@ pub fn create(rt: &Runtime) {
create_with_content_and_header(rt, &path, String::new(),
Entry::default_header())
}
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(&path).unwrap_or_exit();
}
diff --git a/bin/core/imag-store/src/delete.rs b/bin/core/imag-store/src/delete.rs
index 31511e8..bc1672b 100644
--- a/bin/core/imag-store/src/delete.rs
+++ b/bin/core/imag-store/src/delete.rs
@@ -29,13 +29,13 @@ pub fn delete(rt: &Runtime) {
let id = scmd.value_of("id").unwrap(); // safe by clap
let path = PathBuf::from(id);
let store = Some(rt.store().path().clone());
- let path = StoreId::new(store, path).map_err_trace_exit_unwrap(1);
+ let path = StoreId::new(store, path).map_err_trace_exit_unwrap();
debug!("Deleting file at {:?}", id);
let _ = rt.store()
.delete(path)
.map_warn_err(|e| format!("Error: {:?}", e))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
#[cfg(test)]
diff --git a/bin/core/imag-store/src/get.rs b/bin/core/imag-store/src/get.rs
index 2f1cf87..582e67d 100644
--- a/bin/core/imag-store/src/get.rs
+++ b/bin/core/imag-store/src/get.rs
@@ -21,6 +21,7 @@ use std::path::PathBuf;
use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagstore::storeid::StoreId;
use retrieve::print_entry;
@@ -31,10 +32,10 @@ pub fn get(rt: &Runtime) {
let id = scmd.value_of("id").unwrap(); // safe by clap
let path = PathBuf::from(id);
let store = Some(rt.store().path().clone());
- let path = StoreId::new(store, path).map_err_trace_exit_unwrap(1);
+ let path = StoreId::new(store, path).map_err_trace_exit_unwrap();
debug!("path = {:?}", path);
- let _ = match rt.store().get(path.clone()).map_err_trace_exit_unwrap(1) {
+ let _ = match rt.store().get(path.clone()).map_err_trace_exit_unwrap() {
Some(entry) => {
print_entry(rt, scmd, entry);
let _ = rt.report_touched(&path).unwrap_or_exit();
diff --git a/bin/core/imag-store/src/main.rs b/bin/core/imag-store/src/main.rs
index acabc3b..7c0c0f1 100644
--- a/bin/core/imag-store/src/main.rs
+++ b/bin/core/imag-store/src/main.rs
@@ -94,7 +94,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-store", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
diff --git a/bin/core/imag-store/src/retrieve.rs b/bin/core/imag-store/src/retrieve.rs
index 4a20d33..e1fafce 100644
--- a/bin/core/imag-store/src/retrieve.rs
+++ b/bin/core/imag-store/src/retrieve.rs
@@ -38,7 +38,7 @@ pub fn retrieve(rt: &Runtime) {
let id = scmd.value_of("id").unwrap();
let path = PathBuf::from(id);
let store = Some(rt.store().path().clone());
- let path = StoreId::new(store, path).map_err_trace_exit_unwrap(1);
+ let path = StoreId::new(store, path).map_err_trace_exit_unwrap();
debug!("path = {:?}", path);
rt.store()
@@ -46,7 +46,7 @@ pub fn retrieve(rt: &Runtime) {
.map(|e| print_entry(rt, scmd, e))
.map_dbg_str("No entry")
.map_dbg(|e| format!("{:?}", e))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(&path).unwrap_or_exit();
});
@@ -55,7 +55,7 @@ pub fn retrieve(rt: &Runtime) {
pub fn print_entry(rt: &Runtime, scmd: &ArgMatches, e: FileLockEntry) {
if do_print_raw(scmd) {
debug!("Printing raw content...");
- let _ = writeln!(rt.stdout(), "{}", e.to_str().map_err_trace_exit_unwrap(1))
+ let _ = writeln!(rt.stdout(), "{}", e.to_str().map_err_trace_exit_unwrap())
.to_exit_code()
.unwrap_or_exit();
} else if do_filter(scmd) {
diff --git a/bin/core/imag-store/src/update.rs b/bin/core/imag-store/src/update.rs
index 1302f3d..cad2fd5 100644
--- a/bin/core/imag-store/src/update.rs
+++ b/bin/core/imag-store/src/update.rs
@@ -22,6 +22,7 @@ use std::path::PathBuf;
use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagstore::storeid::StoreId;
use util::build_toml_header;
@@ -31,7 +32,7 @@ pub fn update(rt: &Runtime) {
let id = scmd.value_of("id").unwrap(); // Safe by clap
let path = PathBuf::from(id);
let store = Some(rt.store().path().clone());
- let path = StoreId::new(store, path).map_err_trace_exit_unwrap(1);
+ let path = StoreId::new(store, path).map_err_trace_exit_unwrap();
let _ = rt.store()
.retrieve(path)
diff --git a/bin/core/imag-store/src/verify.rs b/bin/core/imag-store/src/verify.rs
index 6f2b96a..c63b7c4 100644
--- a/bin/core/imag-store/src/verify.rs
+++ b/bin/core/imag-store/src/verify.rs
@@ -22,6 +22,7 @@ use std::ops::Deref;
use libimagrt::runtime::Runtime;
use libimagutil::warn_exit::warn_exit;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagerror::iter::TraceIterator;
/// Verify the store.
@@ -33,9 +34,9 @@ pub fn verify(rt: &Runtime) {
let result = rt
.store()
.entries()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter()
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.filter_map(|x| x)
.all(|fle| {
let p = fle.get_location();
diff --git a/bin/core/imag-tag/src/main.rs b/bin/core/imag-tag/src/main.rs
index 982d50e..ddf3fa7 100644
--- a/bin/core/imag-tag/src/main.rs
+++ b/bin/core/imag-tag/src/main.rs
@@ -84,7 +84,7 @@ fn main() {
"Direct interface to the store. Use with great care!",
build_ui);
- let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap(1);
+ let ids = rt.ids::<::ui::PathProvider>().map_err_trace_exit_unwrap();
rt.cli()
.subcommand_name()
@@ -107,7 +107,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-tag", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -161,7 +161,7 @@ fn alter(rt: &Runtime, path: StoreId, add: Option<Vec<Tag>>, rem: Option<Vec<Tag
}
fn list(path: StoreId, rt: &Runtime) {
- let entry = match rt.store().get(path.clone()).map_err_trace_exit_unwrap(1) {
+ let entry = match rt.store().get(path.clone()).map_err_trace_exit_unwrap() {
Some(e) => e,
None => warn_exit("No entry found.", 1),
};
@@ -178,7 +178,7 @@ fn list(path: StoreId, rt: &Runtime) {
comm_out = true;
}
- let tags = entry.get_tags().map_err_trace_exit_unwrap(1);
+ let tags = entry.get_tags().map_err_trace_exit_unwrap();
if json_out {
unimplemented!()
diff --git a/bin/core/imag-tag/src/ui.rs b/bin/core/imag-tag/src/ui.rs
index db31b6c..77684d9 100644
--- a/bin/core/imag-tag/src/ui.rs
+++ b/bin/core/imag-tag/src/ui.rs
@@ -108,7 +108,7 @@ impl IdPathProvider for PathProvider {
fn get_ids(matches: &ArgMatches) -> Vec<StoreId> {
matches.values_of("id")
.unwrap()
- .map(|s| PathBuf::from(s).into_storeid().map_err_trace_exit_unwrap(1))
+ .map(|s| PathBuf::from(s).into_storeid().map_err_trace_exit_unwrap())
.collect()
}
}
diff --git a/bin/core/imag-view/src/main.rs b/bin/core/imag-view/src/main.rs
index 08c6c0d..1dca0c7 100644
--- a/bin/core/imag-view/src/main.rs
+++ b/bin/core/imag-view/src/main.rs
@@ -83,15 +83,15 @@ fn main() {
let view_header = rt.cli().is_present("view-header");
let hide_content = rt.cli().is_present("not-view-content");
let entries = rt.ids::<::ui::PathProvider>()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_iter()
.map(Ok)
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|e| {
e.ok_or_else(|| err_msg("Entry not found"))
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
});
if rt.cli().is_present("in") {
@@ -108,19 +108,19 @@ fn main() {
.cli()
.value_of("in")
.ok_or_else(|| Error::from(err_msg("No viewer given")))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let config = rt
.config()
.ok_or_else(|| Error::from(err_msg("No configuration, cannot continue")))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let query = format!("view.viewers.{}", viewer);
let viewer_template = config
.read_string(&query)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("Cannot find '{}' in config", query);
exit(1)
@@ -132,7 +132,7 @@ fn main() {
let _ = handlebars
.register_template_string("template", viewer_template)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let mut data = BTreeMap::new();
@@ -147,12 +147,12 @@ fn main() {
let call = handlebars
.render("template", &data)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let mut elems = call.split_whitespace();
let command_string = elems
.next()
.ok_or_else(|| Error::from(err_msg("No command")))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let mut cmd = Command::new(command_string);
for arg in elems {
@@ -167,7 +167,7 @@ fn main() {
if !command
.status()
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.success()
{
exit(1)
@@ -206,7 +206,7 @@ fn main() {
viewer
.view_entry(&entry, &mut outlock)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
rt.report_touched(entry.get_location()).unwrap_or_exit();
});
@@ -240,7 +240,7 @@ fn main() {
viewer
.view_entry(&entry, &mut outlock)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
rt.report_touched(entry.get_location()).unwrap_or_exit();
});
@@ -253,21 +253,21 @@ fn create_tempfile_for<'a>(entry: &FileLockEntry<'a>, view_header: bool, hide_co
{
let mut tmpfile = tempfile::NamedTempFile::new()
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
if view_header {
let hdr = toml::ser::to_string_pretty(entry.get_header())
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = tmpfile.write(format!("---\n{}---\n", hdr).as_bytes())
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
if !hide_content {
let _ = tmpfile.write(entry.get_content().as_bytes())
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
let file_path = tmpfile
@@ -275,7 +275,7 @@ fn create_tempfile_for<'a>(entry: &FileLockEntry<'a>, view_header: bool, hide_co
.to_str()
.map(String::from)
.ok_or_else(|| Error::from(err_msg("Cannot build path")))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
(tmpfile, file_path)
}
diff --git a/bin/core/imag-view/src/ui.rs b/bin/core/imag-view/src/ui.rs
index c55c15b..e01d707 100644
--- a/bin/core/imag-view/src/ui.rs
+++ b/bin/core/imag-view/src/ui.rs
@@ -93,7 +93,7 @@ impl IdPathProvider for PathProvider {
fn get_ids(matches: &ArgMatches) -> Vec<StoreId> {
matches.values_of("id")
.unwrap()
- .map(|s| PathBuf::from(s).into_storeid().map_err_trace_exit_unwrap(1))
+ .map(|s| PathBuf::from(s).into_storeid().map_err_trace_exit_unwrap())
.collect()
}
}
diff --git a/bin/domain/imag-bookmark/src/main.rs b/bin/domain/imag-bookmark/src/main.rs
index e5c4208..c7b942c 100644
--- a/bin/domain/imag-bookmark/src/main.rs
+++ b/bin/domain/imag-bookmark/src/main.rs
@@ -84,7 +84,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-bookmark", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -97,16 +97,16 @@ fn add(rt: &Runtime) {
let coll = get_collection_name(rt, "add", "collection");
let mut collection = BookmarkCollectionStore::get(rt.store(), &coll)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| format_err!("No bookmark collection '{}' found", coll))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(collection.get_location()).unwrap_or_exit();
for url in scmd.values_of("urls").unwrap() { // unwrap saved by clap
let new_ids = collection
.add_link(rt.store(), BookmarkLink::from(url))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_all_touched(new_ids.into_iter()).unwrap_or_exit();
}
@@ -143,16 +143,16 @@ fn list(rt: &Runtime) {
let coll = get_collection_name(rt, "list", "collection");
let collection = BookmarkCollectionStore::get(rt.store(), &coll)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| format_err!("No bookmark collection '{}' found", coll))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(collection.get_location()).unwrap_or_exit();
collection
.links(rt.store())
.map_dbg_str("Listing...")
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_iter()
.enumerate()
.for_each(|(i, link)| match link {
@@ -167,16 +167,16 @@ fn remove(rt: &Runtime) {
let coll = get_collection_name(rt, "list", "collection");
let mut collection = BookmarkCollectionStore::get(rt.store(), &coll)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| format_err!("No bookmark collection '{}' found", coll))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(collection.get_location()).unwrap_or_exit();
for url in scmd.values_of("urls").unwrap() { // enforced by clap
let removed_links = collection
.remove_link(rt.store(), BookmarkLink::from(url))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_all_touched(removed_links.into_iter()).unwrap_or_exit();
}
@@ -198,7 +198,7 @@ fn get_collection_name(rt: &Runtime,
.map(|cfg| {
cfg.read_string("bookmark.default_collection")
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| {
error!("Missing config: 'bookmark.default_collection'. Set or use commandline to specify.");
exit(1)
diff --git a/bin/domain/imag-contact/src/create.rs b/bin/domain/imag-contact/src/create.rs
index 082ed92..622a2cc 100644
--- a/bin/domain/imag-contact/src/create.rs
+++ b/bin/domain/imag-contact/src/create.rs
@@ -51,6 +51,7 @@ use libimagcontact::store::ContactStore;
use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
use libimagerror::trace::trace_error;
+use libimagerror::exit::ExitUnwrap;
use libimagutil::warn_result::WarnResult;
const TEMPLATE : &'static str = include_str!("../static/new-contact-template.toml");
@@ -75,7 +76,7 @@ mod test {
fn ask_continue(inputstream: &mut Read, outputstream: &mut Write) -> bool {
::libimaginteraction::ask::ask_bool("Edit tempfile", Some(true), inputstream, outputstream)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
}
pub fn create(rt: &Runtime) {
@@ -122,7 +123,7 @@ pub fn create(rt: &Runtime) {
.open(fl.clone())
.map_warn_err_str("Cannot create/open destination File. Stopping.")
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let uuid_string = uuid
.unwrap_or_else(|| {
@@ -153,7 +154,7 @@ pub fn create(rt: &Runtime) {
loop {
::libimagentryedit::edit::edit_in_tmpfile(&rt, &mut template)
.map_warn_err_str("Editing failed.")
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
if template == TEMPLATE || template.is_empty() {
error!("No (changed) content in tempfile. Not doing anything.");
@@ -179,7 +180,7 @@ pub fn create(rt: &Runtime) {
Ok(Some(vcard)) => {
if template == TEMPLATE || template.is_empty() {
if ::libimaginteraction::ask::ask_bool("Abort contact creating", Some(false), &mut input, &mut output)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
{
exit(1)
} else {
@@ -191,7 +192,7 @@ pub fn create(rt: &Runtime) {
let _ = dest
.write_all(&vcard_string.as_bytes())
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
break;
}
@@ -202,7 +203,7 @@ pub fn create(rt: &Runtime) {
if !scmd.is_present("dont-track") {
let entry = rt.store()
.create_from_path(&location)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(entry.get_location()).unwrap_or_exit();
@@ -253,7 +254,7 @@ fn parse_toml_into_vcard(output: &mut Write, input: &mut Read, toml: Value, uuid
{ // parse nicknames
debug!("Parsing nicknames");
- match toml.read("nickname").map_err(Error::from).map_err_trace_exit_unwrap(1) {
+ match toml.read("nickname").map_err(Error::from).map_err_trace_exit_unwrap() {
Some(&Value::Array(ref ary)) => {
for (i, element) in ary.iter().enumerate() {
let nicktype = match read_str_from_toml(element, "type", false) {
@@ -323,7 +324,7 @@ fn parse_toml_into_vcard(output: &mut Write, input: &mut Read, toml: Value, uuid
{ // parse phone
debug!("Parse phone");
- match toml.read("person.phone").map_err(Error::from).map_err_trace_exit_unwrap(1) {
+ match toml.read("person.phone").map_err(Error::from).map_err_trace_exit_unwrap() {
Some(&Value::Array(ref ary)) => {
for (i, element) in ary.iter().enumerate() {
let phonetype = match read_str_from_toml(element, "type", false) {
@@ -373,7 +374,7 @@ fn parse_toml_into_vcard(output: &mut Write, input: &mut Read, toml: Value, uuid
{ // parse address
debug!("Parsing address");
- match toml.read("addresses").map_err(Error::from).map_err_trace_exit_unwrap(1) {
+ match toml.read("addresses").map_err(Error::from).map_err_trace_exit_unwrap() {
Some(&Value::Array(ref ary)) => {
for (i, element) in ary.iter().enumerate() {
let adrtype = match read_str_from_toml(element, "type", false) {
@@ -428,7 +429,7 @@ fn parse_toml_into_vcard(output: &mut Write, input: &mut Read, toml: Value, uuid
{ // parse email
debug!("Parsing email");
- match toml.read("person.email").map_err(Error::from).map_err_trace_exit_unwrap(1) {
+ match toml.read("person.email").map_err(Error::from).map_err_trace_exit_unwrap() {
Some(&Value::Array(ref ary)) => {
for (i, element) in ary.iter().enumerate() {
let mailtype = match read_str_from_toml(element, "type", false) {
diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs
index e97bd9b..0775378 100644
--- a/bin/domain/imag-contact/src/main.rs
+++ b/bin/domain/imag-contact/src/main.rs
@@ -104,7 +104,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-contact", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -119,17 +119,17 @@ fn list(rt: &Runtime) {
let iterator = rt
.store()
.all_contacts()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|fle| fle.ok_or_else(|| Error::from(err_msg("StoreId not found".to_owned()))))
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|fle| {
let _ = rt.report_touched(fle.get_location()).unwrap_or_exit();
fle
})
.map(|e| e.deser())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.enumerate();
if scmd.is_present("json") {
@@ -148,7 +148,7 @@ fn list(rt: &Runtime) {
iterator
.map(|(i, dvcard)| build_data_object_for_handlebars(i, &dvcard))
.map(|data| list_format.render("format", &data).map_err(Error::from))
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.for_each(|s| {
writeln!(output, "{}", s).to_exit_code().unwrap_or_exit()
});
@@ -168,21 +168,21 @@ fn import(rt: &Runtime) {
let entry = rt
.store()
.retrieve_from_path(&path)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(entry.get_location()).unwrap_or_exit();
} else if path.is_dir() {
for entry in WalkDir::new(path).min_depth(1).into_iter() {
let entry = entry
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
if entry.file_type().is_file() {
let pb = PathBuf::from(entry.path());
let fle = rt
.store()
.retrieve_from_path(&pb)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(fle.get_location()).unwrap_or_exit();
info!("Imported: {}", entry.path().to_str().unwrap_or("<non UTF-8 path>"));
@@ -205,15 +205,15 @@ fn show(rt: &Runtime) {
rt.store()
.all_contacts()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|o| o.unwrap_or_else(|| {
error!("Failed to get entry");
exit(1)
}))
.filter_map(|entry| {
- let deser = entry.deser().map_err_trace_exit_unwrap(1);
+ let deser = entry.deser().map_err_trace_exit_unwrap();
if deser.uid()
.ok_or_else(|| {
@@ -236,7 +236,7 @@ fn show(rt: &Runtime) {
let s = show_format
.render("format", &data)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = writeln!(outlock, "{}", s).to_exit_code().unwrap_or_exit();
});
}
@@ -256,10 +256,10 @@ fn find(rt: &Runtime) {
let iterator = rt
.store()
.all_contacts()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter(rt.store())
.map(|el| {
- el.map_err_trace_exit_unwrap(1)
+ el.map_err_trace_exit_unwrap()
.ok_or_else(|| {
error!("Could not get StoreId from Store::all_contacts(). This is a BUG!");
::std::process::exit(1)
@@ -267,7 +267,7 @@ fn find(rt: &Runtime) {
.unwrap() // safed above
})
.filter_map(|entry| {
- let card = entry.deser().map_err_trace_exit_unwrap(1);
+ let card = entry.deser().map_err_trace_exit_unwrap();
let str_contains_any = |s: &String, v: &Vec<String>| {
v.iter().any(|i| s.contains(i))
@@ -329,7 +329,7 @@ fn find(rt: &Runtime) {
let s = fmt
.render("format", &data)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = writeln!(rt.stdout(), "{}", s)
.to_exit_code()
@@ -348,19 +348,19 @@ fn get_contact_print_format(config_value_path: &'static str, rt: &Runtime, scmd:
.unwrap_or_else(|| {
rt.config()
.ok_or_else(|| Error::from(err_msg("No configuration file")))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.read_string(config_value_path)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| Error::from(err_msg("Configuration 'contact.list_format' does not exist")))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
});
let mut hb = Handlebars::new();
let _ = hb
.register_template_string("format", fmt)
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
hb.register_escape_fn(::handlebars::no_escape);
::libimaginteraction::format::register_all_color_helpers(&mut hb);
diff --git a/bin/domain/imag-diary/src/create.rs b/bin/domain/imag-diary/src/create.rs
index 7e7c47b..423a701 100644
--- a/bin/domain/imag-diary/src/create.rs
+++ b/bin/domain/imag-diary/src/create.rs
@@ -29,6 +29,7 @@ use libimagdiary::diary::Diary;
use libimagentryedit::edit::Edit;
use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagutil::warn_exit::warn_exit;
use libimagutil::debug_result::DebugResult;
use libimagutil::debug_option::DebugOption;
@@ -55,7 +56,7 @@ pub fn create(rt: &Runtime) {
entry.edit_content(rt).context(err_msg("Diary edit error")).map_err(Error::from)
};
- let _ = res.map_err_trace_exit_unwrap(1);
+ let _ = res.map_err_trace_exit_unwrap();
info!("Ok!");
}
@@ -65,10 +66,10 @@ fn create_entry<'a>(diary: &'a Store, diaryname: &str, rt: &Runtime) -> FileLock
let create = rt.cli().subcommand_matches("create").unwrap();
create.value_of("timed")
- .map(|t| parse_timed_string(t, diaryname).map_err_trace_exit_unwrap(1))
+ .map(|t| parse_timed_string(t, diaryname).map_err_trace_exit_unwrap())
.map(Some)
.unwrap_or_else(|| {
- match get_diary_timed_config(rt, diaryname).map_err_trace_exit_unwrap(1) {
+ match get_diary_timed_config(rt, diaryname).map_err_trace_exit_unwrap() {
Some(t) => Some(t),
None => {
warn!("Missing config: 'diary.diaries.{}.timed'", diaryname);
@@ -88,7 +89,7 @@ fn create_entry<'a>(diary: &'a Store, diaryname: &str, rt: &Runtime) -> FileLock
diary.new_entry_today(diaryname)
})
.map_dbg(|e| format!("Created: {}", e.get_location()))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
}
diff --git a/bin/domain/imag-diary/src/delete.rs b/bin/domain/imag-diary/src/delete.rs
index af719ca..1230180 100644
--- a/bin/domain/imag-diary/src/delete.rs
+++ b/bin/domain/imag-diary/src/delete.rs
@@ -28,6 +28,7 @@ use libimagtimeui::parse::Parse;
use libimagutil::warn_exit::warn_exit;
use libimagstore::storeid::IntoStoreId;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use util::get_diary_name;
@@ -48,7 +49,7 @@ pub fn delete(rt: &Runtime) {
.ok_or_else(|| warn_exit("Not deleting entries: missing date/time specification", 1))
.and_then(|dt: NDT| DiaryId::from_datetime(diaryname.clone(), dt).into_storeid())
.and_then(|id| rt.store().retrieve(id))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.get_location()
.clone();
@@ -60,7 +61,7 @@ pub fn delete(rt: &Runtime) {
let mut output = rt.stdout();
if !ask_bool(&format!("Deleting {:?}", to_del_location), Some(true), &mut input, &mut output)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
{
info!("Aborting delete action");
return;
@@ -71,7 +72,7 @@ pub fn delete(rt: &Runtime) {
let _ = rt
.store()
.delete(to_del_location)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
info!("Ok!");
}
diff --git a/bin/domain/imag-diary/src/list.rs b/bin/domain/imag-diary/src/list.rs
index ce6d748..b551bd1 100644
--- a/bin/domain/imag-diary/src/list.rs
+++ b/bin/domain/imag-diary/src/list.rs
@@ -41,11 +41,11 @@ pub fn list(rt: &Runtime) {
let mut ids = Diary::entries(rt.store(), &diaryname)
.map_dbg_str("Ok")
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.map(|id| DiaryId::from_storeid(&id))
.collect::<Result<Vec<_>>>()
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
ids.sort_by_key(|id| {
[id.year() as u32, id.month(), id.day(), id.hour(), id.minute(), id.second()]
@@ -53,7 +53,7 @@ pub fn list(rt: &Runtime) {
ids.into_iter()
.map(IntoStoreId::into_storeid)
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.for_each(|id| {
let _ = rt.report_touched(&id).unwrap_or_exit();
diff --git a/bin/domain/imag-diary/src/main.rs b/bin/domain/imag-diary/src/main.rs
index 3764601..055911c 100644
--- a/bin/domain/imag-diary/src/main.rs
+++ b/bin/domain/imag-diary/src/main.rs
@@ -92,7 +92,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-diary", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -111,8 +111,8 @@ fn diaries(rt: &Runtime) {
rt.store()
.diary_names()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.unique()
.for_each(|n| writeln!(outlock, "{}", n).to_exit_code().unwrap_or_exit())
}
diff --git a/bin/domain/imag-diary/src/view.rs b/bin/domain/imag-diary/src/view.rs
index dd1c4d6..9f0acba 100644
--- a/bin/domain/imag-diary/src/view.rs
+++ b/bin/domain/imag-diary/src/view.rs
@@ -22,6 +22,7 @@ use libimagdiary::viewer::DiaryViewer as DV;
use libimagrt::runtime::Runtime;
use libimagerror::trace::MapErrTrace;
use libimagerror::iter::TraceIterator;
+use libimagerror::exit::ExitUnwrap;
use libimagutil::warn_exit::warn_exit;
use libimagstore::iter::get::StoreIdGetIteratorExtension;
use libimagentryview::viewer::Viewer;
@@ -33,9 +34,9 @@ pub fn view(rt: &Runtime) {
let hdr = rt.cli().subcommand_matches("view").unwrap().is_present("show-header");
let entries = Diary::entries(rt.store(), &diaryname)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|e| e.unwrap_or_else(|| {
error!("Failed to fetch entry");
::std::process::exit(1)
@@ -49,6 +50,6 @@ pub fn view(rt: &Runtime) {
let out = rt.stdout();
DV::new(hdr).view_entries(entries, &mut out.lock())
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
diff --git a/bin/domain/imag-habit/src/main.rs b/bin/domain/imag-habit/src/main.rs
index 3a822ee..0f637ea 100644
--- a/bin/domain/imag-habit/src/main.rs
+++ b/bin/domain/imag-habit/src/main.rs
@@ -99,7 +99,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-habit", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -117,10 +117,10 @@ fn create(rt: &Runtime) {
let comm = scmd.value_of("create-comment").map(String::from).unwrap(); // safe by clap
let date = scmd.value_of("create-date").unwrap(); // safe by clap
- let parsedate = |d, pname| match kairos_parse(d).map_err_trace_exit_unwrap(1) {
+ let parsedate = |d, pname| match kairos_parse(d).map_err_trace_exit_unwrap() {
Parsed::TimeType(tt) => tt.calculate()
.map_dbg(|y| format!("TimeType yielded: '{:?}'", y))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.get_moment()
.ok_or_else(|| {
error!("Error: '{}' parameter does not yield a point in time", pname);
@@ -154,7 +154,7 @@ fn create(rt: &Runtime) {
debug!("Builder = {:?}", hb);
- let fle = hb.build(rt.store()).map_err_trace_exit_unwrap(1);
+ let fle = hb.build(rt.store()).map_err_trace_exit_unwrap();
let _ = rt.report_touched(fle.get_location()).unwrap_or_exit();
}
@@ -176,11 +176,11 @@ fn delete(rt: &Runtime) {
let _ = rt
.store()
.all_habit_templates()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
- .map(|sid| (sid.clone(), rt.store().get(sid).map_err_trace_exit_unwrap(1))) // get the FileLockEntry
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
+ .map(|sid| (sid.clone(), rt.store().get(sid).map_err_trace_exit_unwrap())) // get the FileLockEntry
.filter(|&(_, ref habit)| match habit { // filter for name of habit == name we look for
- &Some(ref h) => h.habit_name().map_err_trace_exit_unwrap(1) == name,
+ &Some(ref h) => h.habit_name().map_err_trace_exit_unwrap() == name,
&None => false,
})
.filter_map(|(a, o)| o.map(|x| (a, x))) // map: (a, Option<b>) -> Option<(a, b)> -> (a, b)
@@ -188,18 +188,18 @@ fn delete(rt: &Runtime) {
if delete_instances {
// if this does not succeed, we did something terribly wrong
- let t_name = fle.habit_name().map_err_trace_exit_unwrap(1);
+ let t_name = fle.habit_name().map_err_trace_exit_unwrap();
assert_eq!(t_name, name);
- let get_instance = |iid| rt.store().get(iid).map_err_trace_exit_unwrap(1);
- let has_template_name = |i: &FileLockEntry| t_name == i.get_template_name().map_err_trace_exit_unwrap(1);
+ let get_instance = |iid| rt.store().get(iid).map_err_trace_exit_unwrap();
+ let has_template_name = |i: &FileLockEntry| t_name == i.get_template_name().map_err_trace_exit_unwrap();
let instance_location = |i: FileLockEntry| i.get_location().clone();
let delete_instance_by_id = |id| {
- let do_delete = |id| rt.store().delete(id).map_err_trace_exit_unwrap(1);
+ let do_delete = |id| rt.store().delete(id).map_err_trace_exit_unwrap();
if !yes {
let q = format!("Really delete {}", id);
if ask_bool(&q, Some(false), &mut input, &mut output)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
{
let _ = do_delete(id);
}
@@ -210,8 +210,8 @@ fn delete(rt: &Runtime) {
let _ = fle
.linked_instances()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.filter_map(get_instance)
.filter(has_template_name)
.map(instance_location)
@@ -221,11 +221,11 @@ fn delete(rt: &Runtime) {
drop(fle);
- let do_delete_template = |sid| rt.store().delete(sid).map_err_trace_exit_unwrap(1);
+ let do_delete_template = |sid| rt.store().delete(sid).map_err_trace_exit_unwrap();
if !yes {
let q = format!("Really delete template {}", sid);
if ask_bool(&q, Some(false), &mut input, &mut output)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
{
let _ = do_delete_template(sid);
}
@@ -267,8 +267,8 @@ fn today(rt: &Runtime, future: bool) {
let mut relevant : Vec<_> = rt
.store()
.all_habit_templates()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.filter_map(|id| match rt.store().get(id.clone()) {
Ok(Some(h)) => Some(h),
Ok(None) => {
@@ -281,7 +281,7 @@ fn today(rt: &Runtime, future: bool) {
},
})
.filter(|h| {
- let due = h.next_instance_date().map_err_trace_exit_unwrap(1);
+ let due = h.next_instance_date().map_err_trace_exit_unwrap();
// today or in future
debug!("Checking {due:?} == {today:?} or (future = {fut} && {due:?} > {today:?}",
due = due, today = today, fut = future);
@@ -290,14 +290,14 @@ fn today(rt: &Runtime, future: bool) {
.collect();
// unwrap is safe because we filtered above
- relevant.sort_by_key(|h| h.next_instance_date().map_err_trace_exit_unwrap(1).unwrap());
+ relevant.sort_by_key(|h| h.next_instance_date().map_err_trace_exit_unwrap().unwrap());
relevant
};
let any_today_relevant = show_done || relevant
.iter()
.filter(|h| {
- let due = h.next_instance_date().map_err_trace_exit_unwrap(1);
+ let due = h.next_instance_date().map_err_trace_exit_unwrap();
debug!("Checking: {:?} == {:?}", due, today);
due.map(|d| d == today).unwrap_or(false) // relevant today
})
@@ -314,7 +314,7 @@ fn today(rt: &Runtime, future: bool) {
x.parse::<usize>()
.context(format_err!("Cannot parse String '{}' to integer", x))
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
})
}).unwrap_or(5);
@@ -322,13 +322,13 @@ fn today(rt: &Runtime, future: bool) {
info!("Upcoming:");
// list `n` which are relevant in the future.
relevant.iter().take(n).for_each(|element| {
- let date = element.next_instance_date().map_err_trace_exit_unwrap(1);
- let name = element.habit_name().map_err_trace_exit_unwrap(1);
+ let date = element.next_instance_date().map_err_trace_exit_unwrap();
+ let name = element.habit_name().map_err_trace_exit_unwrap();
if let Some(date) = date {
let is_done = element
.instance_exists_for_date(&date)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
if show_done || !is_done {
info!(" * {date}: {name}", date = date, name = name);
@@ -338,13 +338,13 @@ fn today(rt: &Runtime, future: bool) {
} else {
fn lister_fn(h: &FileLockEntry) -> Vec<String> {
debug!("Listing: {:?}", h);
- let name = h.habit_name().map_err_trace_exit_unwrap(1);
- let basedate = h.habit_basedate().map_err_trace_exit_unwrap(1);
- let recur = h.habit_recur_spec().map_err_trace_exit_unwrap(1);
- let due = h.next_instance_date().map_err_trace_exit_unwrap(1)
+ let name = h.habit_name().map_err_trace_exit_unwrap();
+ let basedate = h.habit_basedate().map_err_trace_exit_unwrap();
+ let recur = h.habit_recur_spec().map_err_trace_exit_unwrap();
+ let due = h.next_instance_date().map_err_trace_exit_unwrap()
.map(date_to_string_helper)
.unwrap_or_else(|| String::from("<finished>"));
- let comm = h.habit_comment().map_err_trace_exit_unwrap(1);
+ let comm = h.habit_comment().map_err_trace_exit_unwrap();
let v = vec![name, basedate, recur, due, comm];
debug!(" -> {:?}", v);
@@ -365,10 +365,10 @@ fn today(rt: &Runtime, future: bool) {
.filter(|habit| show_done || {
habit
.next_instance_date()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|date| {
habit.instance_exists_for_date(&date)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
})
.unwrap_or(false)
})
@@ -380,7 +380,7 @@ fn today(rt: &Runtime, future: bool) {
{
let _ = rt
.report_touched(e.get_location())
- .map_err_trace_exit_unwrap(1);
+ .unwrap_or_exit();
}
v.append(&mut list);
@@ -397,11 +397,11 @@ fn today(rt: &Runtime, future: bool) {
fn list(rt: &Runtime) {
fn lister_fn(h: &FileLockEntry) -> Vec<String> {
debug!("Listing: {:?}", h);
- let name = h.habit_name().map_err_trace_exit_unwrap(1);
- let basedate = h.habit_basedate().map_err_trace_exit_unwrap(1);
- let recur = h.habit_recur_spec().map_err_trace_exit_unwrap(1);
- let comm = h.habit_comment().map_err_trace_exit_unwrap(1);
- let due = h.next_instance_date().map_err_trace_exit_unwrap(1)
+ let name = h.habit_name().map_err_trace_exit_unwrap();
+ let basedate = h.habit_basedate().map_err_trace_exit_unwrap();
+ let recur = h.habit_recur_spec().map_err_trace_exit_unwrap();
+ let comm = h.habit_comment().map_err_trace_exit_unwrap();
+ let due = h.next_instance_date().map_err_trace_exit_unwrap()
.map(date_to_string_helper)
.unwrap_or_else(|| String::from("<finished>"));
@@ -422,8 +422,8 @@ fn list(rt: &Runtime) {
let _ = rt
.store()
.all_habit_templates()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.filter_map(|id| match rt.store().get(id.clone()) {
Ok(Some(h)) => Some(h),
Ok(None) => {
@@ -465,8 +465,8 @@ fn show(rt: &Runtime) {
use libimagutil::date::date_to_string;
use libimaghabit::instance::HabitInstance;
- let date = date_to_string(&i.get_date().map_err_trace_exit_unwrap(1));
- let comm = i.get_comment().map_err_trace_exit_unwrap(1);
+ let date = date_to_string(&i.get_date().map_err_trace_exit_unwrap());
+ let comm = i.get_comment().map_err_trace_exit_unwrap();
vec![date, comm]
}
@@ -482,16 +482,16 @@ fn show(rt: &Runtime) {
let _ = rt
.store()
.all_habit_templates()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.filter_map(|id| get_from_store(rt.store(), id))
- .filter(|h| h.habit_name().map(|n| name == n).map_err_trace_exit_unwrap(1))
+ .filter(|h| h.habit_name().map(|n| name == n).map_err_trace_exit_unwrap())
.enumerate()
.map(|(i, habit)| {
- let name = habit.habit_name().map_err_trace_exit_unwrap(1);
- let basedate = habit.habit_basedate().map_err_trace_exit_unwrap(1);
- let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap(1);
- let comm = habit.habit_comment().map_err_trace_exit_unwrap(1);
+ let name = habit.habit_name().map_err_trace_exit_unwrap();
+ let basedate = habit.habit_basedate().map_err_trace_exit_unwrap();
+ let recur = habit.habit_recur_spec().map_err_trace_exit_unwrap();
+ let comm = habit.habit_comment().map_err_trace_exit_unwrap();
let _ = writeln!(rt.stdout(),
"{i} - {name}\nBase : {b},\nRecurrence: {r}\nComment : {c}\n",
@@ -506,11 +506,11 @@ fn show(rt: &Runtime) {
let mut empty = true;
let _ = habit
.linked_instances()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.filter_map(|instance_id| {
debug!("Getting: {:?}", instance_id);
- rt.store().get(instance_id).map_err_trace_exit_unwrap(1)
+ rt.store().get(instance_id).map_err_trace_exit_unwrap()
})
.enumerate()
.for_each(|(i, e)| {
@@ -543,31 +543,31 @@ fn done(rt: &Runtime) {
let mut relevant : Vec<_> = rt
.store()
.all_habit_templates()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.filter_map(|id| get_from_store(rt.store(), id))
.filter(|h| {
- let due = h.next_instance_date().map_err_trace_exit_unwrap(1);
+ let due = h.next_instance_date().map_err_trace_exit_unwrap();
due.map(|d| (d == today || d < today) || scmd.is_present("allow-future"))
.unwrap_or(false)
})
.filter(|h| {
- names.contains(&h.habit_name().map_err_trace_exit_unwrap(1))
+ names.contains(&h.habit_name().map_err_trace_exit_unwrap())
})
.collect();
// unwrap is safe because we filtered above
- relevant.sort_by_key(|h| h.next_instance_date().map_err_trace_exit_unwrap(1).unwrap());
+ relevant.sort_by_key(|h| h.next_instance_date().map_err_trace_exit_unwrap().unwrap());
relevant
};
for mut r in relevant {
- let next_instance_name = r.habit_name().map_err_trace_exit_unwrap(1);
- let next_instance_date = r.next_instance_date().map_err_trace_exit_unwrap(1);
+ let next_instance_name = r.habit_name().map_err_trace_exit_unwrap();
+ let next_instance_date = r.next_instance_date().map_err_trace_exit_unwrap();
if let Some(next) = next_instance_date {
debug!("Creating new instance on {:?}", next);
r.create_instance_with_date(rt.store(), &next)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
info!("Done on {date}: {name}",
date = libimagutil::date::date_to_string(&next),
diff --git a/bin/domain/imag-log/src/main.rs b/bin/domain/imag-log/src/main.rs
index 525eff7..a96bf5a 100644
--- a/bin/domain/imag-log/src/main.rs
+++ b/bin/domain/imag-log/src/main.rs
@@ -84,7 +84,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-log", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -102,10 +102,10 @@ fn main() {
.store()
.new_entry_now(&diary_name)
.map(|mut fle| {
- let _ = fle.make_log_entry().map_err_trace_exit_unwrap(1);
+ let _ = fle.make_log_entry().map_err_trace_exit_unwrap();
*fle.get_content_mut() = text;
})
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
}
@@ -118,18 +118,18 @@ fn show(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("show").unwrap(); // safed by main()
let iters : Vec<DiaryEntryIterator> = match scmd.values_of("show-name") {
Some(values) => values
- .map(|diary_name| Diary::entries(rt.store(), diary_name).map_err_trace_exit_unwrap(1))
+ .map(|diary_name| Diary::entries(rt.store(), diary_name).map_err_trace_exit_unwrap())
.collect(),
None => if scmd.is_present("show-all") {
debug!("Showing for all diaries");
rt.store()
.diary_names()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|diary_name| {
- let diary_name = diary_name.map_err_trace_exit_unwrap(1);
+ let diary_name = diary_name.map_err_trace_exit_unwrap();
debug!("Getting entries for Diary: {}", diary_name);
- let entries = Diary::entries(rt.store(), &diary_name).map_err_trace_exit_unwrap(1);
+ let entries = Diary::entries(rt.store(), &diary_name).map_err_trace_exit_unwrap();
let diary_name = Cow::from(diary_name);
(entries, diary_name)
})
@@ -138,13 +138,13 @@ fn show(rt: &Runtime) {
.collect()
} else {
// showing default logs
- vec![Diary::entries(rt.store(), &get_diary_name(rt)).map_err_trace_exit_unwrap(1)]
+ vec![Diary::entries(rt.store(), &get_diary_name(rt)).map_err_trace_exit_unwrap()]
}
};
Itertools::flatten(iters.into_iter())
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.filter_map(|opt| {
if opt.is_none() {
warn!("Failed to retrieve an entry from an existing store id");
@@ -152,8 +152,8 @@ fn show(rt: &Runtime) {
opt
})
- .filter(|e| e.is_log().map_err_trace_exit_unwrap(1))
- .map(|entry| (entry.diary_id().map_err_trace_exit_unwrap(1), entry))
+ .filter(|e| e.is_log().map_err_trace_exit_unwrap())
+ .map(|entry| (entry.diary_id().map_err_trace_exit_unwrap(), entry))
.sorted_by_key(|tpl| tpl.0.clone())
.into_iter()
.map(|tpl| { debug!("Found entry: {:?}", tpl.1); tpl })
@@ -185,24 +185,24 @@ fn get_diary_name(rt: &Runtime) -> String {
let cfg = rt
.config()
.ok_or_else(|| Error::from(err_msg("Configuration not present, cannot continue")))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let current_log = cfg
.read_string("log.default")
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| Error::from(err_msg("Configuration missing: 'log.default'")))
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
if cfg
.read("log.logs")
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.ok_or_else(|| Error::from(err_msg("Configuration missing: 'log.logs'")))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.as_array()
.ok_or_else(|| Error::from(err_msg("Configuration 'log.logs' is not an Array")))
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.iter()
.map(|e| if is_match!(e, &Value::String(_)) {
error!("Configuration 'log.logs' is not an Array<String>!");
diff --git a/bin/domain/imag-mail/src/main.rs b/bin/domain/imag-mail/src/main.rs
index 0a7da7f..d9b9dfb 100644
--- a/bin/domain/imag-mail/src/main.rs
+++ b/bin/domain/imag-mail/src/main.rs
@@ -79,7 +79,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-mail", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
}
@@ -93,7 +93,7 @@ fn import_mail(rt: &Runtime) {
let mail = Mail::import_from_path(rt.store(), path)
.map_info_str("Ok")
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(mail.fle().get_location()).unwrap_or_exit();
}
@@ -152,15 +152,15 @@ fn list(rt: &Runtime) {
let _ = rt.store()
.entries()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.filter(|id| id.is_in_collection(&["mail"]))
.filter_map(|id| {
rt.store()
.get(id)
.context(err_msg("Ref handling error"))
.map_err(Error::from)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|fle| Mail::from_fle(fle).map_err_trace().ok())
})
.filter_map(|e| e)
diff --git a/bin/domain/imag-notes/src/main.rs b/bin/domain/imag-notes/src/main.rs
index 2d9c03b..3d7be38 100644
--- a/bin/domain/imag-notes/src/main.rs
+++ b/bin/domain/imag-notes/src/main.rs
@@ -86,7 +86,7 @@ fn main() {
other => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-notes", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
},
@@ -103,13 +103,13 @@ fn create(rt: &Runtime) {
let mut note = rt
.store()
.new_note(name.clone(), String::new())
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
if rt.cli().subcommand_matches("create").unwrap().is_present("edit") {
let _ = note
.edit_content(rt)
.map_warn_err_str("Editing failed")
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
let _ = rt.report_touched(note.get_location()).unwrap_or_exit();
@@ -119,7 +119,7 @@ fn delete(rt: &Runtime) {
let _ = rt.store()
.delete_note(name_from_cli(rt, "delete"))
.map_info_str("Ok")
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
fn edit(rt: &Runtime) {
@@ -127,12 +127,12 @@ fn edit(rt: &Runtime) {
let _ = rt
.store()
.get_note(name.clone())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|mut note| {
let _ = note
.edit_content(rt)
.map_warn_err_str("Editing failed")
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = rt.report_touched(note.get_location()).unwrap_or_exit();
})
@@ -147,9 +147,9 @@ fn list(rt: &Runtime) {
let _ = rt
.store()
.all_notes()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.into_get_iter(rt.store())
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|opt| opt.unwrap_or_else(|| {
error!("Fatal: Nonexistent entry where entry should exist");
exit(1)
@@ -161,7 +161,7 @@ fn list(rt: &Runtime) {
})
.iter()
.for_each(|note| {
- let name = note.get_name().map_err_trace_exit_unwrap(1);
+ let name = note.get_name().map_err_trace_exit_unwrap();
let _ = writeln!(rt.stdout(), "{}", name)
.to_exit_code()
.unwrap_or_exit();
diff --git a/bin/domain/imag-timetrack/src/cont.rs b/bin/domain/imag-timetrack/src/cont.rs
index 60ab955..b979681 100644
--- a/bin/domain/imag-timetrack/src/cont.rs
+++ b/bin/domain/imag-timetrack/src/cont.rs
@@ -26,6 +26,7 @@ use chrono::NaiveDateTime;
use libimagerror::trace::trace_error;
use libimagerror::trace::MapErrTrace;
use libimagerror::iter::TraceIterator;
+use libimagerror::exit::ExitUnwrap;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
use libimagtimetrack::timetracking::TimeTracking;
use libimagtimetrack::iter::filter::*;
@@ -35,7 +36,7 @@ use libimagrt::runtime::Runtime;
pub fn cont(rt: &Runtime) -> i32 {
let groups = rt.store()
.get_timetrackings()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
.filter(|e| has_end_time.filter(&e))
.group_by(|elem| match elem.get_end_datetime() { // Now group them by the end time
@@ -98,6 +99,6 @@ pub fn cont(rt: &Runtime) -> i32 {
info!("No trackings to continue");
Ok(1)
},
- }.map_err_trace_exit_unwrap(1)
+ }.map_err_trace_exit_unwrap()
}
diff --git a/bin/domain/imag-timetrack/src/day.rs b/bin/domain/imag-timetrack/src/day.rs
index 6a09904..b38f4b6 100644
--- a/bin/domain/imag-timetrack/src/day.rs
+++ b/bin/domain/imag-timetrack/src/day.rs
@@ -28,6 +28,7 @@ use libimagerror::trace::trace_error;
use libimagerror::trace::MapErrTrace;
use libimagerror::iter::TraceIterator;
use libimagerror::io::ToExitCode;
+use libimagerror::exit::ExitUnwrap;
use libimagstore::store::FileLockEntry;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
use libimagtimetrack::timetracking::TimeTracking;
@@ -88,7 +89,7 @@ pub fn day(rt: &Runtime) -> i32 {
rt.store()
.get_timetrackings()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
.filter(|e| filter.filter(e))
.map(|e| -> Result<_, Error> {
@@ -107,7 +108,7 @@ pub fn day(rt: &Runtime) -> i32 {
Ok((tag, start, end))
})
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|(tag, start, end)| {
match (start, end) {
(None, _) => writeln!(rt.stdout(), "{} has no start time.", tag),
diff --git a/bin/domain/imag-timetrack/src/list.rs b/bin/domain/imag-timetrack/src/list.rs
index 2e79412..738f1bb 100644
--- a/bin/domain/imag-timetrack/src/list.rs
+++ b/bin/domain/imag-timetrack/src/list.rs
@@ -33,6 +33,7 @@ use failure::Error;
use libimagerror::trace::trace_error;
use libimagerror::trace::MapErrTrace;
use libimagerror::iter::TraceIterator;
+use libimagerror::exit::ExitUnwrap;
use libimagstore::store::FileLockEntry;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
use libimagtimetrack::timetracking::TimeTracking;
@@ -122,7 +123,7 @@ pub fn list_impl(rt: &Runtime,
rt.store()
.get_timetrackings()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
.filter(|e| filter.filter(e))
.fold(Ok(table), |acc: Result<_>, e| {
@@ -167,7 +168,7 @@ pub fn list_impl(rt: &Runtime,
Ok(tab)
})
})
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.print(&mut rt.stdout())
.context(err_msg("Failed to print table"))
.map_err(Error::from)
diff --git a/bin/domain/imag-timetrack/src/main.rs b/bin/domain/imag-timetrack/src/main.rs
index 16c6fff..7ae23d9 100644
--- a/bin/domain/imag-timetrack/src/main.rs
+++ b/bin/domain/imag-timetrack/src/main.rs
@@ -99,7 +99,7 @@ fn main() {
other => {
debug!("Unknown command");
rt.handle_unknown_subcommand("imag-timetrack", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.unwrap_or(0)
},
diff --git a/bin/domain/imag-timetrack/src/month.rs b/bin/domain/imag-timetrack/src/month.rs
index f5bf99d..e2b840b 100644
--- a/bin/domain/imag-timetrack/src/month.rs
+++ b/bin/domain/imag-timetrack/src/month.rs
@@ -28,6 +28,7 @@ use libimagerror::trace::trace_error;
use libimagerror::trace::MapErrTrace;
use libimagerror::io::ToExitCode;
use libimagerror::iter::TraceIterator;
+use libimagerror::exit::ExitUnwrap;
use libimagstore::store::FileLockEntry;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
use libimagtimetrack::timetracking::TimeTracking;
@@ -103,7 +104,7 @@ pub fn month(rt: &Runtime) -> i32 {
rt.store()
.get_timetrackings()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
.filter(|e| filter.filter(e))
.map(|e| -> Result<_, Error> {
@@ -118,11 +119,11 @@ pub fn month(rt: &Runtime) -> i32 {
let end = e.get_end_datetime()?;
debug!(" -> end = {:?}", end);
- let _ = rt.report_touched(e.get_location()).unwrap_or_exit(1);
+ let _ = rt.report_touched(e.get_location()).unwrap_or_exit();
Ok((tag, start, end))
})
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|(tag, start, end)| {
match (start, end) {
(None, _) => writeln!(rt.stdout(), "{} has no start time.", tag),
diff --git a/bin/domain/imag-timetrack/src/start.rs b/bin/domain/imag-timetrack/src/start.rs
index 39ddea4..165286e 100644
--- a/bin/domain/imag-timetrack/src/start.rs
+++ b/bin/domain/imag-timetrack/src/start.rs
@@ -24,7 +24,7 @@ use failure::Error;
use libimagrt::runtime::Runtime;
use libimagerror::trace::trace_error;
-use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagtimetrack::tag::TimeTrackingTag;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
diff --git a/bin/domain/imag-timetrack/src/stop.rs b/bin/domain/imag-timetrack/src/stop.rs
index 2fc27be..286fc1d 100644
--- a/bin/domain/imag-timetrack/src/stop.rs
+++ b/bin/domain/imag-timetrack/src/stop.rs
@@ -26,6 +26,7 @@ use failure::Error;
use libimagerror::trace::trace_error;
use libimagerror::iter::TraceIterator;
use libimagerror::trace::MapErrTrace;
+use libimagerror::exit::ExitUnwrap;
use libimagrt::runtime::Runtime;
use libimagtimetrack::timetracking::TimeTracking;
@@ -57,12 +58,12 @@ pub fn stop(rt: &Runtime) -> i32 {
// Get all timetrackings which do not have an end datetime.
rt.store()
.get_timetrackings()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
.filter_map(|tracking| {
let is_none = tracking
.get_end_datetime()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.is_none();
if is_none {
@@ -72,7 +73,7 @@ pub fn stop(rt: &Runtime) -> i32 {
}
})
.map(|t| t.get_timetrack_tag())
- .map(|r| r.map_err_trace_exit_unwrap(1))
+ .map(|r| r.map_err_trace_exit_unwrap())
.collect()
});
@@ -82,7 +83,7 @@ pub fn stop(rt: &Runtime) -> i32 {
.store()
.get_timetrackings()
.map_warn_err_str("Getting timetrackings failed")
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
// Filter all timetrackings for the ones that are not yet ended.
diff --git a/bin/domain/imag-timetrack/src/track.rs b/bin/domain/imag-timetrack/src/track.rs
index f89047a..d3fa7ad 100644
--- a/bin/domain/imag-timetrack/src/track.rs
+++ b/bin/domain/imag-timetrack/src/track.rs
@@ -26,9 +26,9 @@ use failure::Error;
use libimagrt::runtime::Runtime;
use libimagerror::trace::trace_error;
+use libimagerror::exit::ExitUnwrap;
use libimagtimetrack::tag::TimeTrackingTag;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
-use libimagerror::trace::MapErrTrace;
const DATE_TIME_PARSE_FMT : &'static str = "%Y-%m-%dT%H:%M:%S";
const DATE_PARSE_FMT : &'static str = "%Y-%m-%d";
diff --git a/bin/domain/imag-timetrack/src/week.rs b/bin/domain/imag-timetrack/src/week.rs
index 5c38403..3c0b252 100644
--- a/bin/domain/imag-timetrack/src/week.rs
+++ b/bin/domain/imag-timetrack/src/week.rs
@@ -28,6 +28,7 @@ use libimagerror::trace::trace_error;
use libimagerror::trace::MapErrTrace;
use libimagerror::iter::TraceIterator;
use libimagerror::io::ToExitCode;
+use libimagerror::exit::ExitUnwrap;
use libimagstore::store::FileLockEntry;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
use libimagtimetrack::timetracking::TimeTracking;
@@ -101,7 +102,7 @@ pub fn week(rt: &Runtime) -> i32 {
rt.store()
.get_timetrackings()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
.filter(|e| filter.filter(e))
.map(|e| -> Result<_, Error> {
@@ -120,7 +121,7 @@ pub fn week(rt: &Runtime) -> i32 {
Ok((tag, start, end))
})
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|(tag, start, end)| {
match (start, end) {
(None, _) => writeln!(rt.stdout(), "{} has no start time.", tag),
diff --git a/bin/domain/imag-timetrack/src/year.rs b/bin/domain/imag-timetrack/src/year.rs
index 16d3005..5e4a438 100644
--- a/bin/domain/imag-timetrack/src/year.rs
+++ b/bin/domain/imag-timetrack/src/year.rs
@@ -28,6 +28,7 @@ use libimagerror::trace::trace_error;
use libimagerror::trace::MapErrTrace;
use libimagerror::iter::TraceIterator;
use libimagerror::io::ToExitCode;
+use libimagerror::exit::ExitUnwrap;
use libimagstore::store::FileLockEntry;
use libimagtimetrack::timetrackingstore::TimeTrackStore;
use libimagtimetrack::timetracking::TimeTracking;
@@ -101,7 +102,7 @@ pub fn year(rt: &Runtime) -> i32 {
let mut out = rt.stdout();
rt.store()
.get_timetrackings()
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.trace_unwrap()
.filter(|e| filter.filter(e))
.map(|e| -> Result<_, Error> {
@@ -120,7 +121,7 @@ pub fn year(rt: &Runtime) -> i32 {
Ok((tag, start, end))
})
- .trace_unwrap_exit(1)
+ .trace_unwrap_exit()
.map(|(tag, start, end)| {
match (start, end) {
(None, _) => writeln!(out, "{} has no start time.", tag),
diff --git a/bin/domain/imag-todo/src/main.rs b/bin/domain/imag-todo/src/main.rs
index acad5e8..d62eabb 100644
--- a/bin/domain/imag-todo/src/main.rs
+++ b/bin/domain/imag-todo/src/main.rs
@@ -74,7 +74,7 @@ fn main() {
Some(other) => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-todo", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(::std::process::exit);
}
@@ -95,7 +95,7 @@ fn tw_hook(rt: &Runtime) {
let (_, line, uuid ) = rt
.store()
.import_task_from_reader(stdin)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let _ = writeln!(rt.stdout(), "{}\nTask {} stored in imag", line, uuid)
.to_exit_code()
@@ -129,7 +129,7 @@ fn list(rt: &Runtime) {
let res = rt.store().all_tasks() // get all tasks
.map(|iter| { // and if this succeeded
// filter out the ones were we can read the uuid
- let uuids : Vec<_> = iter.trace_unwrap_exit(1).filter_map(|storeid| {
+ let uuids : Vec<_> = iter.trace_unwrap_exit().filter_map(|storeid| {
match rt.store().retrieve(storeid) {
Ok(fle) => {
match fle.get_header().read_string("todo.uuid") {
diff --git a/bin/domain/imag-wiki/src/main.rs b/bin/domain/imag-wiki/src/main.rs
index a32960f..17f0825 100644
--- a/bin/domain/imag-wiki/src/main.rs
+++ b/bin/domain/imag-wiki/src/main.rs
@@ -65,7 +65,7 @@ fn main() {
Some(other) => {
debug!("Unknown command");
let _ = rt.handle_unknown_subcommand("imag-wiki", other, rt.cli())
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.code()
.map(std::process::exit);
}
@@ -86,14 +86,14 @@ fn ids(rt: &Runtime, wiki_name: &str) {
rt.store()
.get_wiki(wiki_name)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("No wiki '{}' found", wiki_name);
::std::process::exit(1)
})
.all_ids()
- .map_err_trace_exit_unwrap(1)
- .trace_unwrap_exit(1)
+ .map_err_trace_exit_unwrap()
+ .trace_unwrap_exit()
.for_each(|id| {
let _ = writeln!(outlock, "{}{}", prefix, id)
.to_exit_code()
@@ -114,13 +114,13 @@ fn idof(rt: &Runtime, wiki_name: &str) {
let _ = rt.store()
.get_wiki(wiki_name)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("No wiki '{}' found", wiki_name);
::std::process::exit(1)
})
.get_entry(&entryname)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.map(|entry| {
let id = entry.get_location().clone();
let prefix = if scmd.is_present("idof-full") {
@@ -147,30 +147,30 @@ fn create(rt: &Runtime, wiki_name: &str) {
let wiki = rt
.store()
.get_wiki(&wiki_name)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("No wiki '{}' found", wiki_name);
::std::process::exit(1)
});
- let mut entry = wiki.create_entry(name).map_err_trace_exit_unwrap(1);
+ let mut entry = wiki.create_entry(name).map_err_trace_exit_unwrap();
if !scmd.is_present("create-noedit") {
if scmd.is_present("create-editheader") {
- let _ = entry.edit_header_and_content(rt).map_err_trace_exit_unwrap(1);
+ let _ = entry.edit_header_and_content(rt).map_err_trace_exit_unwrap();
} else {
- let _ = entry.edit_content(rt).map_err_trace_exit_unwrap(1);
+ let _ = entry.edit_content(rt).map_err_trace_exit_unwrap();
}
}
let _ = entry.autolink(rt.store())
.map_warn_err_str("Linking has failed. Trying to safe the entry now. Please investigate by hand if this succeeds.")
.map_err(|e| {
- let _ = rt.store().update(&mut entry).map_err_trace_exit_unwrap(1);
+ let _ = rt.store().update(&mut entry).map_err_trace_exit_unwrap();
e
})
.map_warn_err_str("Safed entry")
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
let id = entry.get_location();
@@ -187,7 +187,7 @@ fn create(rt: &Runtime, wiki_name: &str) {
fn create_wiki(rt: &Runtime) {
let scmd = rt.cli().subcommand_matches("create-wiki").unwrap(); // safed by clap
let wiki_name = String::from(scmd.value_of("create-wiki-name").unwrap()); // safe by clap
- let (_, index) = rt.store().create_wiki(&wiki_name).map_err_trace_exit_unwrap(1);
+ let (_, index) = rt.store().create_wiki(&wiki_name).map_err_trace_exit_unwrap();
let _ = rt.report_touched(index.get_location()).unwrap_or_exit();
}
@@ -221,7 +221,7 @@ fn show(rt: &Runtime, wiki_name: &str) {
let wiki = rt
.store()
.get_wiki(&wiki_name)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("No wiki '{}' found", wiki_name);
::std::process::exit(1)
@@ -233,7 +233,7 @@ fn show(rt: &Runtime, wiki_name: &str) {
for name in names {
let entry = wiki
.get_entry(&name)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("No wiki entry '{}' found in wiki '{}'", name, wiki_name);
::std::process::exit(1)
@@ -261,7 +261,7 @@ fn delete(rt: &Runtime, wiki_name: &str) {
let wiki = rt
.store()
.get_wiki(&wiki_name)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("No wiki '{}' found", wiki_name);
::std::process::exit(1)
@@ -269,17 +269,17 @@ fn delete(rt: &Runtime, wiki_name: &str) {
if unlink {
wiki.get_entry(&name)
- .map_err_trace_exit_unwrap(1)
+ .map_err_trace_exit_unwrap()
.unwrap_or_else(|| {
error!("No wiki entry '{}' in '{}' found", name, wiki_name);
::std::process::exit(1)
})
.unlink(rt.store())
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
let _ = wiki
.delete_entry(&name)
- .map_err_trace_exit_unwrap(1);
+ .map_err_trace_exit_unwrap();
}
diff --git a/lib/core/libimagerror/src/iter.rs b/lib/core/libimagerror/src/iter.rs
index 2c00a56..b146ebe 100644
--- a/lib/core/libimagerror/src/iter.rs
+++ b/lib/core/libimagerror/src/iter.rs
@@ -59,7 +59,7 @@ impl<I, F, T> Iterator for UnwrapWith<I, F>
/// Iterator helper for Unwrap with exiting on error
-pub struct UnwrapExit<I, T>(I, i32)
+pub struct UnwrapExit<I, T>(I)
where I: Iterator<Item = Result<T, Error>>;
impl<I, T> Iterator for UnwrapExit<I, T>
@@ -69,7 +69,7 @@ impl<I, T> Iterator for UnwrapExit<I, T>
fn next(&mut self) -> Option<Self::Item> {
use trace::MapErrTrace;
- self.0.next().map(|e| e.map_err_trace_exit_unwrap(self.1))
+ self.0.next().map(|e| e.map_err_trace_exit_unwrap())
}
}
@@ -78,7 +78,7 @@ impl<I, T> DoubleEndedIterator for UnwrapExit<I, T>
{
fn next_back(&mut self) -> Option<Self::Item> {
use trace::MapErrTrace;
- self.0.next_back().map(|e| e.map_err_trace_exit_unwrap(self.1))
+ self.0.next_back().map(|e| e.map_err_trace_exit_unwrap())
}
}
@@ -111,8 +111,8 @@ pub trait TraceIterator<T> : Iterator<Item = Result<T, Error>> + Sized {
/// nothing will be passed to `::trace::trace_error_exit`, no matter how many `Err` items might
/// be present.
#[inline]
- fn trace_unwrap_exit(self, exitcode: i32) -> UnwrapExit<Self, T> {
- UnwrapExit(self, exitcode)
+ fn trace_unwrap_exit(self) -> UnwrapExit<Self, T> {
+ UnwrapExit(self)
}
diff --git a/lib/core/libimagerror/src/trace.rs b/lib/core/libimagerror/src/trace.rs
index bad4e11..7894426 100644
--- a/lib/core/libimagerror/src/trace.rs
+++ b/lib/core/libimagerror/src/trace.rs
@@ -73,7 +73,7 @@ pub trait MapErrTrace {
type Output;
fn map_err_trace(self) -> Self;
- fn map_err_trace_exit_unwrap(self, code: i32) -> Self::Output;
+ fn map_err_trace_exit_unwrap(self) -> Self::Output;
}
impl<U> MapErrTrace for Result<U, Error> {
@@ -87,8 +87,8 @@ impl<U> MapErrTrace for Result<U, Error> {
}
/// Trace the error and exit or unwrap the Ok(_).
- fn map_err_trace_exit_unwrap(self, code: i32) -> Self::Output {
- self.map_err(|e| { trace_error(&e); exit(code) }).unwrap()
+ fn map_err_trace_exit_unwrap(self) -> Self::Output {
+ self.map_err(|e| { trace_error(&e); exit(1) }).unwrap()
}
}