Add force-override option to "imag-contact import"
This patch adds the option to force-override the ref data in the imported entries. This is necessary when importing contact data which is already in the store, but where the reference data has changed (for example if the hash of the file has changed, this might come in handy at some point). Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
ff5e6653ed
commit
41e981fa48
2 changed files with 11 additions and 4 deletions
|
@ -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();
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue