Add flag to not print name of annotation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
ab5078f111
commit
c84258da3d
2 changed files with 24 additions and 11 deletions
|
@ -52,6 +52,7 @@ extern crate libimagentrylink;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
use toml_query::read::TomlValueReadTypeExt;
|
||||||
|
|
||||||
use libimagentryannotation::annotateable::*;
|
use libimagentryannotation::annotateable::*;
|
||||||
use libimagentryannotation::annotation_fetcher::*;
|
use libimagentryannotation::annotation_fetcher::*;
|
||||||
|
@ -119,17 +120,20 @@ fn add(rt: &Runtime) {
|
||||||
let _ = entry.add_internal_link(&mut annotation).map_err_trace_exit_unwrap(1);
|
let _ = entry.add_internal_link(&mut annotation).map_err_trace_exit_unwrap(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(annotation_id) = annotation
|
if !scmd.is_present("dont-print-name") {
|
||||||
.get_header()
|
if let Some(annotation_id) = annotation
|
||||||
.read_string("annotation.name")
|
.get_header()
|
||||||
.map_err_trace_exit_unwrap(1)
|
.read_string("annotation.name")
|
||||||
{
|
.map_err(Error::from)
|
||||||
let _ = writeln!(rt.stdout(), "Name of the annotation: {}", annotation_id)
|
.map_err_trace_exit_unwrap(1)
|
||||||
.to_exit_code()
|
{
|
||||||
.unwrap_or_exit(1);
|
let _ = writeln!(rt.stdout(), "Name of the annotation: {}", annotation_id)
|
||||||
} else {
|
.to_exit_code()
|
||||||
error!("Unnamed annotation: {:?}", annotation.get_location());
|
.unwrap_or_exit();
|
||||||
error!("This is most likely a BUG, please report!");
|
} else {
|
||||||
|
error!("Unnamed annotation: {:?}", annotation.get_location());
|
||||||
|
error!("This is most likely a BUG, please report!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug!("No entries to annotate");
|
debug!("No entries to annotate");
|
||||||
|
|
|
@ -31,6 +31,15 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> {
|
||||||
.subcommand(SubCommand::with_name("add")
|
.subcommand(SubCommand::with_name("add")
|
||||||
.about("Add annotation to an entry")
|
.about("Add annotation to an entry")
|
||||||
.version("0.1")
|
.version("0.1")
|
||||||
|
|
||||||
|
.arg(Arg::with_name("dont-print-name")
|
||||||
|
.short("N")
|
||||||
|
.long("no-name")
|
||||||
|
.takes_value(false)
|
||||||
|
.required(false)
|
||||||
|
.multiple(false)
|
||||||
|
.help("Do not print the name of the annotation after annotating.")
|
||||||
|
)
|
||||||
.arg(Arg::with_name("entry")
|
.arg(Arg::with_name("entry")
|
||||||
.index(1)
|
.index(1)
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
|
|
Loading…
Reference in a new issue