diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-02-05 20:12:19 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-02-10 00:58:21 +0100 |
commit | c84258da3d2a5f62cc6cfae3c0c04a933c1fbb3d (patch) | |
tree | f856a903000f183b575bbd123b1fd8d97d3ffb25 | |
parent | ab5078f1119156ceddf7cac37960aa09ebe507d3 (diff) |
Add flag to not print name of annotation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | bin/core/imag-annotate/src/main.rs | 26 | ||||
-rw-r--r-- | bin/core/imag-annotate/src/ui.rs | 9 |
2 files changed, 24 insertions, 11 deletions
diff --git a/bin/core/imag-annotate/src/main.rs b/bin/core/imag-annotate/src/main.rs index 8699463a..03153fb8 100644 --- a/bin/core/imag-annotate/src/main.rs +++ b/bin/core/imag-annotate/src/main.rs @@ -52,6 +52,7 @@ extern crate libimagentrylink; use std::io::Write; use failure::Error; +use toml_query::read::TomlValueReadTypeExt; use libimagentryannotation::annotateable::*; 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); } - if let Some(annotation_id) = annotation - .get_header() - .read_string("annotation.name") - .map_err_trace_exit_unwrap(1) - { - let _ = writeln!(rt.stdout(), "Name of the annotation: {}", annotation_id) - .to_exit_code() - .unwrap_or_exit(1); - } else { - error!("Unnamed annotation: {:?}", annotation.get_location()); - error!("This is most likely a BUG, please report!"); + if !scmd.is_present("dont-print-name") { + if let Some(annotation_id) = annotation + .get_header() + .read_string("annotation.name") + .map_err(Error::from) + .map_err_trace_exit_unwrap(1) + { + let _ = writeln!(rt.stdout(), "Name of the annotation: {}", annotation_id) + .to_exit_code() + .unwrap_or_exit(); + } else { + error!("Unnamed annotation: {:?}", annotation.get_location()); + error!("This is most likely a BUG, please report!"); + } } } else { debug!("No entries to annotate"); diff --git a/bin/core/imag-annotate/src/ui.rs b/bin/core/imag-annotate/src/ui.rs index ab17f744..024d6a3d 100644 --- a/bin/core/imag-annotate/src/ui.rs +++ b/bin/core/imag-annotate/src/ui.rs @@ -31,6 +31,15 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .subcommand(SubCommand::with_name("add") .about("Add annotation to an entry") .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") .index(1) .takes_value(true) |