From 3dfb17aabdfbd10d7142c63b79493095d2439064 Mon Sep 17 00:00:00 2001
From: Matthias Beyer <mail@beyermatthias.de>
Date: Fri, 6 Apr 2018 14:45:26 +0200
Subject: [PATCH] Add functionality to find contacts and print the storeid/file
 path

---
 bin/domain/imag-contact/src/main.rs | 15 +++++++++++++++
 bin/domain/imag-contact/src/ui.rs   | 23 +++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs
index e8dda553..e277dcfc 100644
--- a/bin/domain/imag-contact/src/main.rs
+++ b/bin/domain/imag-contact/src/main.rs
@@ -305,6 +305,21 @@ fn find(rt: &Runtime) {
                 ::std::process::exit(1)
             }
         }
+    } else if scmd.is_present("find-id") {
+        iterator
+        .for_each(|(_i, (fle, _card))| {
+            writeln!(rt.stdout(), "{}", fle.get_location())
+                .to_exit_code()
+                .unwrap_or_exit();
+        })
+    } else if scmd.is_present("find-full-id") {
+        let storepath = rt.store().path().display();
+        iterator
+        .for_each(|(_i, (fle, _card))| {
+            writeln!(rt.stdout(), "{}/{}", storepath, fle.get_location())
+                .to_exit_code()
+                .unwrap_or_exit();
+        })
     } else {
         iterator
         .for_each(|(i, (fle, card))| {
diff --git a/bin/domain/imag-contact/src/ui.rs b/bin/domain/imag-contact/src/ui.rs
index 3a22a650..6e637296 100644
--- a/bin/domain/imag-contact/src/ui.rs
+++ b/bin/domain/imag-contact/src/ui.rs
@@ -129,6 +129,29 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
                         .conflicts_with("find-show")
                         .conflicts_with("find-list"))
 
+                   .arg(Arg::with_name("find-id")
+                        .long("id")
+                        .takes_value(false)
+                        .required(false)
+                        .multiple(false)
+                        .help("Print the store ids of the found entries")
+                        .conflicts_with("find-full-id")
+                        .conflicts_with("json")
+                        .conflicts_with("find-show")
+                        .conflicts_with("find-list"))
+
+                   .arg(Arg::with_name("find-full-id")
+                        .long("full-id")
+                        .takes_value(false)
+                        .required(false)
+                        .multiple(false)
+                        .help("Print the path to the file in the store of the found entries")
+                        .conflicts_with("find-id")
+                        .conflicts_with("json")
+                        .conflicts_with("find-show")
+                        .conflicts_with("find-list"))
+
+
                    )
 
         .subcommand(SubCommand::with_name("create")