summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2017-01-25 11:23:06 +0100
committerGitHub <noreply@github.com>2017-01-25 11:23:06 +0100
commit636bfbb768f23c92d581ab660fcaa88927c859b1 (patch)
treecb20e5584b47a2016ca5b7dafb22c66d8bc41d7c
parentcd684b04ab696e7456d6ba6e51ebabcf96cb7f0f (diff)
parentddd4a8b94a7edaf308e6e5a70baf65c12464f2d7 (diff)
downloadimag-636bfbb768f23c92d581ab660fcaa88927c859b1.zip
imag-636bfbb768f23c92d581ab660fcaa88927c859b1.tar.gz
Merge pull request #842 from matthiasbeyer/imag-link/list-internal-only
Fix: Only list internal links here, no external ones
-rw-r--r--imag-link/src/main.rs6
-rw-r--r--imag-link/src/ui.rs7
2 files changed, 13 insertions, 0 deletions
diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs
index 6f68668..42928b2 100644
--- a/imag-link/src/main.rs
+++ b/imag-link/src/main.rs
@@ -84,6 +84,7 @@ fn main() {
fn handle_internal_linking(rt: &Runtime) {
use libimagentrylink::internal::InternalLinker;
+ use libimagentrylink::external::is_external_link_storeid;
debug!("Handle internal linking call");
let cmd = rt.cli().subcommand_matches("internal").unwrap();
@@ -96,6 +97,11 @@ fn handle_internal_linking(rt: &Runtime) {
match get_entry_by_name(rt, entry) {
Ok(Some(e)) => {
e.get_internal_links()
+ .map(|iter| {
+ iter.filter(move |id| {
+ cmd.is_present("list-externals-too") || !is_external_link_storeid(&id)
+ })
+ })
.map(|links| {
let i = links
.filter_map(|l| {
diff --git a/imag-link/src/ui.rs b/imag-link/src/ui.rs
index 5c3c3ef..0c2a4e1 100644
--- a/imag-link/src/ui.rs
+++ b/imag-link/src/ui.rs
@@ -71,6 +71,13 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.required(false)
.help("List links to this entry")
.value_name("ENTRY"))
+
+
+ .arg(Arg::with_name("list-externals-too")
+ .long("list-external")
+ .takes_value(false)
+ .required(false)
+ .help("If --list is provided, also list external links (debugging helper that might be removed at some point"))
)
.subcommand(SubCommand::with_name("external")
.about("Add and remove external links")