From 7ecef14e1b976690de147e36f9b849566fbb74e6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 4 Jul 2017 19:23:15 +0200 Subject: [PATCH] Export store-consistency-check from libimagentrylink in UI --- imag-link/src/main.rs | 14 ++++++++++++++ imag-link/src/ui.rs | 7 +++++++ 2 files changed, 21 insertions(+) diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index aec3bbaf..2585ed00 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -84,10 +84,24 @@ fn main() { } fn handle_internal_linking(rt: &Runtime) { + use libimagentrylink::internal::store_check::StoreLinkConsistentExt; debug!("Handle internal linking call"); let cmd = rt.cli().subcommand_matches("internal").unwrap(); + if cmd.is_present("check-consistency") { + match rt.store().check_link_consistency() { + Ok(_) => { + info!("Store is consistent"); + return; + } + Err(e) => { + trace_error(&e); + ::std::process::exit(1); + } + } + } + match cmd.value_of("list") { Some(list) => handle_internal_linking_list_call(rt, cmd, list), None => { diff --git a/imag-link/src/ui.rs b/imag-link/src/ui.rs index 0c2a4e13..2b83fb1e 100644 --- a/imag-link/src/ui.rs +++ b/imag-link/src/ui.rs @@ -78,6 +78,13 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .takes_value(false) .required(false) .help("If --list is provided, also list external links (debugging helper that might be removed at some point")) + + .arg(Arg::with_name("check-consistency") + .long("check-consistency") + .short("C") + .takes_value(false) + .required(false) + .help("Check the link-consistency in the store (might be time-consuming)")) ) .subcommand(SubCommand::with_name("external") .about("Add and remove external links")