Add autolinking
This commit is contained in:
parent
e1ffa4b107
commit
8ea3f62fbc
2 changed files with 14 additions and 0 deletions
|
@ -32,4 +32,5 @@ libimagerror = { version = "0.7.0", path = "../../../lib/core/libimagerr
|
||||||
libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" }
|
libimagrt = { version = "0.7.0", path = "../../../lib/core/libimagrt" }
|
||||||
libimagstore = { version = "0.7.0", path = "../../../lib/core/libimagstore" }
|
libimagstore = { version = "0.7.0", path = "../../../lib/core/libimagstore" }
|
||||||
libimagwiki = { version = "0.7.0", path = "../../../lib/domain/libimagwiki" }
|
libimagwiki = { version = "0.7.0", path = "../../../lib/domain/libimagwiki" }
|
||||||
|
libimagutil = { version = "0.7.0", path = "../../../lib/etc/libimagutil" }
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ extern crate libimagstore;
|
||||||
extern crate libimagwiki;
|
extern crate libimagwiki;
|
||||||
extern crate libimagentryedit;
|
extern crate libimagentryedit;
|
||||||
extern crate libimagentrylink;
|
extern crate libimagentrylink;
|
||||||
|
extern crate libimagutil;
|
||||||
|
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
@ -177,6 +178,9 @@ fn create_in_wiki(rt: &Runtime,
|
||||||
editheader_flag: &'static str,
|
editheader_flag: &'static str,
|
||||||
printid_flag: &'static str)
|
printid_flag: &'static str)
|
||||||
{
|
{
|
||||||
|
use libimagwiki::entry::WikiEntry;
|
||||||
|
use libimagutil::warn_result::WarnResult;
|
||||||
|
|
||||||
let mut entry = wiki.create_entry(entry_name).map_err_trace_exit_unwrap(1);
|
let mut entry = wiki.create_entry(entry_name).map_err_trace_exit_unwrap(1);
|
||||||
|
|
||||||
if !scmd.is_present(noedit_flag) {
|
if !scmd.is_present(noedit_flag) {
|
||||||
|
@ -187,6 +191,15 @@ fn create_in_wiki(rt: &Runtime,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let _ = entry.autolink(rt.store())
|
||||||
|
.map_warn_err_str("Linking has failed. Trying to safe the entry now. Please investigate by hand if this succeeds.")
|
||||||
|
.map_err(|e| {
|
||||||
|
let _ = rt.store().update(&mut entry).map_err_trace_exit_unwrap(1);
|
||||||
|
e
|
||||||
|
})
|
||||||
|
.map_warn_err_str("Safed entry")
|
||||||
|
.map_err_trace_exit_unwrap(1);
|
||||||
|
|
||||||
if scmd.is_present(printid_flag) {
|
if scmd.is_present(printid_flag) {
|
||||||
let out = rt.stdout();
|
let out = rt.stdout();
|
||||||
let mut lock = out.lock();
|
let mut lock = out.lock();
|
||||||
|
|
Loading…
Reference in a new issue