imag-link: Add option for directional linking
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
69ea42dcad
commit
a79f902d70
2 changed files with 15 additions and 1 deletions
|
@ -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))?;
|
||||
|
||||
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())?;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue