Merge pull request #829 from matthiasbeyer/imag-link/reduce-unwraps
Imag link/reduce unwraps
This commit is contained in:
commit
13c57aa0ce
1 changed files with 74 additions and 79 deletions
|
@ -88,9 +88,10 @@ fn handle_internal_linking(rt: &Runtime) {
|
||||||
debug!("Handle internal linking call");
|
debug!("Handle internal linking call");
|
||||||
let cmd = rt.cli().subcommand_matches("internal").unwrap();
|
let cmd = rt.cli().subcommand_matches("internal").unwrap();
|
||||||
|
|
||||||
if cmd.is_present("list") {
|
match cmd.value_of("list") {
|
||||||
|
Some(list) => {
|
||||||
debug!("List...");
|
debug!("List...");
|
||||||
for entry in cmd.value_of("list").unwrap().split(',') {
|
for entry in list.split(',') {
|
||||||
debug!("Listing for '{}'", entry);
|
debug!("Listing for '{}'", entry);
|
||||||
match get_entry_by_name(rt, entry) {
|
match get_entry_by_name(rt, entry) {
|
||||||
Ok(Some(e)) => {
|
Ok(Some(e)) => {
|
||||||
|
@ -124,22 +125,17 @@ fn handle_internal_linking(rt: &Runtime) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug!("Listing ready!");
|
debug!("Listing ready!");
|
||||||
} else {
|
},
|
||||||
let mut from = {
|
None => {
|
||||||
let from = get_from_entry(&rt);
|
let mut from = match get_from_entry(&rt) {
|
||||||
if from.is_none() {
|
None => warn_exit("No 'from' entry", 1),
|
||||||
warn_exit("No 'from' entry", 1);
|
Some(s) => s,
|
||||||
}
|
|
||||||
from.unwrap()
|
|
||||||
};
|
};
|
||||||
debug!("Link from = {:?}", from.deref());
|
debug!("Link from = {:?}", from.deref());
|
||||||
|
|
||||||
let to = {
|
let to = match get_to_entries(&rt) {
|
||||||
let to = get_to_entries(&rt);
|
None => warn_exit("No 'to' entry", 1),
|
||||||
if to.is_none() {
|
Some(to) => to,
|
||||||
warn_exit("No 'to' entry", 1);
|
|
||||||
}
|
|
||||||
to.unwrap()
|
|
||||||
};
|
};
|
||||||
debug!("Link to = {:?}", to.iter().map(|f| f.deref()).collect::<Vec<&Entry>>());
|
debug!("Link to = {:?}", to.iter().map(|f| f.deref()).collect::<Vec<&Entry>>());
|
||||||
|
|
||||||
|
@ -163,6 +159,7 @@ fn handle_internal_linking(rt: &Runtime) {
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_from_entry<'a>(rt: &'a Runtime) -> Option<FileLockEntry<'a>> {
|
fn get_from_entry<'a>(rt: &'a Runtime) -> Option<FileLockEntry<'a>> {
|
||||||
|
@ -216,16 +213,14 @@ fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result<Option<FileLockE
|
||||||
fn handle_external_linking(rt: &Runtime) {
|
fn handle_external_linking(rt: &Runtime) {
|
||||||
let scmd = rt.cli().subcommand_matches("external").unwrap();
|
let scmd = rt.cli().subcommand_matches("external").unwrap();
|
||||||
let entry_name = scmd.value_of("id").unwrap(); // enforced by clap
|
let entry_name = scmd.value_of("id").unwrap(); // enforced by clap
|
||||||
let entry = get_entry_by_name(rt, entry_name);
|
let mut entry = match get_entry_by_name(rt, entry_name) {
|
||||||
if entry.is_err() {
|
Err(e) => trace_error_exit(&e, 1),
|
||||||
trace_error_exit(&entry.unwrap_err(), 1);
|
Ok(None) => {
|
||||||
}
|
|
||||||
let entry = entry.unwrap();
|
|
||||||
if entry.is_none() {
|
|
||||||
warn!("Entry not found: {:?}", entry_name);
|
warn!("Entry not found: {:?}", entry_name);
|
||||||
return;
|
return;
|
||||||
}
|
},
|
||||||
let mut entry = entry.unwrap();
|
Ok(Some(entry)) => entry
|
||||||
|
};
|
||||||
|
|
||||||
if scmd.is_present("add") {
|
if scmd.is_present("add") {
|
||||||
debug!("Adding link to entry!");
|
debug!("Adding link to entry!");
|
||||||
|
|
Loading…
Reference in a new issue