summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-11-02 17:50:08 +0100
committerMatthias Beyer <mail@beyermatthias.de>2019-11-02 17:50:08 +0100
commit1f858cf4bd88c9f674ca1994c38a12a826b3257e (patch)
tree69ac2ca20f3cd246b7bbb07d005194bea0794a7f
parent8270646283e6402642626a3cf53d1c8c8decb78f (diff)
parenta79f902d701405c040f7118004eff2881d27a54e (diff)
downloadimag-1f858cf4bd88c9f674ca1994c38a12a826b3257e.zip
imag-1f858cf4bd88c9f674ca1994c38a12a826b3257e.tar.gz
Merge branch 'imag-link-direction' into master
-rw-r--r--bin/core/imag-link/src/lib.rs7
-rw-r--r--bin/core/imag-link/src/ui.rs9
2 files changed, 15 insertions, 1 deletions
diff --git a/bin/core/imag-link/src/lib.rs b/bin/core/imag-link/src/lib.rs
index 1da4172..9d4f640 100644
--- a/bin/core/imag-link/src/lib.rs
+++ b/bin/core/imag-link/src/lib.rs
@@ -140,6 +140,7 @@ fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockE
fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I) -> Result<()>
where I: Iterator<Item = &'a str>
{
+ let directional = rt.cli().is_present("directional");
let mut from_entry = get_entry_by_name(rt, from)?.ok_or_else(|| err_msg("No 'from' entry"))?;
for entry in to {
@@ -168,7 +169,11 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I) -> Result<()>
.get(entr_id)?
.ok_or_else(|| format_err!("No 'to' entry: {}", entry))?;
- from_entry.add_link(&mut to_entry)?;
+ if directional {
+ from_entry.add_link_to(&mut to_entry)?;
+ } else {
+ from_entry.add_link(&mut to_entry)?;
+ }
rt.report_touched(to_entry.get_location())?;
}
diff --git a/bin/core/imag-link/src/ui.rs b/bin/core/imag-link/src/ui.rs
index 634a609..cde5fef 100644
--- a/bin/core/imag-link/src/ui.rs
+++ b/bin/core/imag-link/src/ui.rs
@@ -107,6 +107,15 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
.help("Link to this entries")
.requires("from")
.value_name("ENTRIES"))
+
+ .arg(Arg::with_name("directional")
+ .long("direction")
+ .takes_value(false)
+ .required(false)
+ .multiple(false)
+ .help("When creating links, make them directional")
+ .requires_all(&["from", "to"]))
+
}
/// PathProvider