diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index 1d2b3a36..1f0a7205 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -2,6 +2,7 @@ extern crate clap; #[macro_use] extern crate semver; extern crate toml; +extern crate url; #[macro_use] extern crate version; extern crate libimaglink; @@ -19,6 +20,9 @@ use libimagstore::store::Entry; use libimagstore::store::FileLockEntry; use libimagstore::store::Store; use libimagutil::trace::trace_error; +use libimaglink::external::ExternalLinker; +use clap::ArgMatches; +use url::Url; mod ui; @@ -49,7 +53,7 @@ fn main() { .map(|name| { match name { "internal" => handle_internal_linking(&rt), - "external" => { unimplemented!() }, + "external" => handle_external_linking(&rt), _ => { warn!("No commandline call"); exit(1); @@ -177,3 +181,119 @@ fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result { + warn!("Could not parse '{}' as URL, ignoring", uri); + trace_error(&e); + None + }, + Ok(u) => Some(u), + } + }) + .filter_map(|x| x) + .collect(); + + if let Err(e) = entry.set_external_links(store, links) { + trace_error(&e); + } else { + info!("Ok"); + } +} + +fn list_links_for_entry(store: &Store, entry: &mut FileLockEntry) { + let res = entry.get_external_links(store) + .and_then(|links| { + let mut i = 0; + for link in links { + println!("{: <3}: {}", i, link); + i += 1; + } + Ok(()) + }); + + match res { + Err(e) => { + trace_error(&e); + }, + Ok(_) => { + info!("Ok"); + }, + } +} +