summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2019-08-27 11:47:12 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-08-28 18:18:41 +0200
commit397bcd43d05d98291afc6e29fb000b82df2d00f1 (patch)
tree9ade612b2e78d64ebda96d7d2e4c6f9e1860d9b7
parent7a97c0258469983cf97a7f4a0eef7119854ad305 (diff)
downloadimag-397bcd43d05d98291afc6e29fb000b82df2d00f1.tar.gz
imag-397bcd43d05d98291afc6e29fb000b82df2d00f1.tar.xz
-rw-r--r--bin/domain/imag-contact/src/main.rs38
-rw-r--r--bin/domain/imag-contact/src/util.rs15
2 files changed, 26 insertions, 27 deletions
diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs
index 8880d670..ac96198b 100644
--- a/bin/domain/imag-contact/src/main.rs
+++ b/bin/domain/imag-contact/src/main.rs
@@ -95,26 +95,24 @@ fn main() {
build_ui);
- rt.cli()
- .subcommand_name()
- .map(|name| {
- debug!("Call {}", name);
- match name {
- "list" => list(&rt),
- "import" => import(&rt),
- "show" => show(&rt),
- "edit" => edit(&rt),
- "find" => find(&rt),
- "create" => create(&rt),
- other => {
- debug!("Unknown command");
- let _ = rt.handle_unknown_subcommand("imag-contact", other, rt.cli())
- .map_err_trace_exit_unwrap()
- .code()
- .map(::std::process::exit);
- },
- }
- });
+ if let Some(name) = rt.cli().subcommand_name() {
+ debug!("Call {}", name);
+ match name {
+ "list" => list(&rt),
+ "import" => import(&rt),
+ "show" => show(&rt),
+ "edit" => edit(&rt),
+ "find" => find(&rt),
+ "create" => create(&rt),
+ other => {
+ debug!("Unknown command");
+ let _ = rt.handle_unknown_subcommand("imag-contact", other, rt.cli())
+ .map_err_trace_exit_unwrap()
+ .code()
+ .map(::std::process::exit);
+ },
+ }
+ }
}
fn list(rt: &Runtime) {
diff --git a/bin/domain/imag-contact/src/util.rs b/bin/domain/imag-contact/src/util.rs
index 2b6a003a..61d061cc 100644
--- a/bin/domain/imag-contact/src/util.rs
+++ b/bin/domain/imag-contact/src/util.rs
@@ -30,7 +30,7 @@ use libimagrt::runtime::Runtime;
use libimagstore::store::FileLockEntry;
-pub fn build_data_object_for_handlebars<'a>(i: usize, vcard: &DeserVcard) -> BTreeMap<&'static str, String> {
+pub fn build_data_object_for_handlebars(i: usize, vcard: &DeserVcard) -> BTreeMap<&'static str, String> {
let mut data = BTreeMap::new();
let process_list = |list: &Vec<String>| {
@@ -96,21 +96,22 @@ pub fn find_contact_by_hash<'a, H: AsRef<str>>(rt: &'a Runtime, hash: H)
error!("Failed to get entry");
exit(1)
}))
- .filter_map(move |entry| {
+ .filter(move |entry| {
let deser = entry.deser().map_err_trace_exit_unwrap();
- if deser.uid()
+ let id_starts_with_hash = deser.uid()
.ok_or_else(|| {
error!("Could not get StoreId from Store::all_contacts(). This is a BUG!");
::std::process::exit(1)
})
.unwrap() // exited above
- .starts_with(hash.as_ref())
- {
+ .starts_with(hash.as_ref());
+
+ if id_starts_with_hash {
rt.report_touched(entry.get_location()).unwrap_or_exit();
- Some(entry)
+ true
} else {
- None
+ false
}
})
}