Merge pull request #842 from matthiasbeyer/imag-link/list-internal-only

Fix: Only list internal links here, no external ones
This commit is contained in:
Matthias Beyer 2017-01-25 11:23:06 +01:00 committed by GitHub
commit 636bfbb768
2 changed files with 13 additions and 0 deletions

View File

@ -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| {

View File

@ -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")