summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-04-22 12:44:24 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-04-22 14:37:43 +0200
commit41e981fa48347eae4395861fab11e47d98031983 (patch)
tree19523031b2fb752e58cef934f29ae27ad2fb08d6
parentff5e6653ed05d0efe8b30261bbf02cc0f762915d (diff)
downloadimag-41e981fa48347eae4395861fab11e47d98031983.tar.gz
imag-41e981fa48347eae4395861fab11e47d98031983.tar.xz
-rw-r--r--bin/domain/imag-contact/src/main.rs9
-rw-r--r--bin/domain/imag-contact/src/ui.rs6
2 files changed, 11 insertions, 4 deletions
diff --git a/bin/domain/imag-contact/src/main.rs b/bin/domain/imag-contact/src/main.rs
index 821d271f..bc950fa1 100644
--- a/bin/domain/imag-contact/src/main.rs
+++ b/bin/domain/imag-contact/src/main.rs
@@ -157,8 +157,9 @@ fn list(rt: &Runtime) {
}
fn import(rt: &Runtime) {
- let scmd = rt.cli().subcommand_matches("import").unwrap(); // secured by main
- let path = scmd.value_of("path").map(PathBuf::from).unwrap(); // secured by clap
+ let scmd = rt.cli().subcommand_matches("import").unwrap(); // secured by main
+ let force_override = scmd.is_present("force-override");
+ let path = scmd.value_of("path").map(PathBuf::from).unwrap(); // secured by clap
let collection_name = rt.cli().value_of("contact-ref-collection-name").unwrap(); // default by clap
let ref_config = rt.config()
@@ -180,7 +181,7 @@ fn import(rt: &Runtime) {
if path.is_file() {
let entry = rt
.store()
- .retrieve_from_path(&path, &ref_config, &collection_name)
+ .retrieve_from_path(&path, &ref_config, &collection_name, force_override)
.map_err_trace_exit_unwrap();
let _ = rt.report_touched(entry.get_location()).unwrap_or_exit();
@@ -194,7 +195,7 @@ fn import(rt: &Runtime) {
let pb = PathBuf::from(entry.path());
let fle = rt
.store()
- .retrieve_from_path(&pb, &ref_config, &collection_name)
+ .retrieve_from_path(&pb, &ref_config, &collection_name, force_override)
.map_err_trace_exit_unwrap();
let _ = rt.report_touched(fle.get_location()).unwrap_or_exit();
diff --git a/bin/domain/imag-contact/src/ui.rs b/bin/domain/imag-contact/src/ui.rs
index 4a0b1095..c07a938d 100644
--- a/bin/domain/imag-contact/src/ui.rs
+++ b/bin/domain/imag-contact/src/ui.rs
@@ -65,6 +65,12 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.value_name("PATH")
.help("Import from this file/directory"))
+ .arg(Arg::with_name("force-override")
+ .long("force")
+ .takes_value(false)
+ .required(false)
+ .multiple(false)
+ .help("Force to override existing entries"))
)
.subcommand(SubCommand::with_name("show")