From 24b64607057e1c8a172a9bc73e14ebc2c5b26b9f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 6 Jan 2016 19:24:37 +0100 Subject: [PATCH 1/5] Add CLI spec for reporting mode --- etc/cli.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/etc/cli.yml b/etc/cli.yml index 553a8f52..4d222a05 100644 --- a/etc/cli.yml +++ b/etc/cli.yml @@ -15,6 +15,11 @@ args: help: Sets the level of debugging information required: false + - report: + long: report + help: Print "Ok" on success, "Error" on failure (except hard errors) before exiting, regardless of verbosity + required: false + - rtp: short: r long: runtimepath From aa30137300aca6ac9825aa7c60c04bf817030a60 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 6 Jan 2016 19:24:48 +0100 Subject: [PATCH 2/5] Add CLI implementation for reporting --- src/cli.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index 6a75b5da..e422f565 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -42,6 +42,13 @@ impl<'a> CliConfig<'a> { self.cli_matches.is_present("debug") } + /** + * Check whether the CLI says we should run with reporting + */ + pub fn report_exit(&self) -> bool { + self.cli_matches.is_present("report") + } + /** * Get the runtime path the CLI configured */ From d9deb9025bf0940b7909572269c5c2f6d2ef76e9 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 6 Jan 2016 19:25:01 +0100 Subject: [PATCH 3/5] Add configuration file parsing for reporting mode --- src/configuration.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/configuration.rs b/src/configuration.rs index b783c734..2fbaf70e 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -19,6 +19,7 @@ pub struct Configuration { pub store_sub : String, pub editor : Option, pub editor_opts : String, + pub report_exit : bool, } impl Configuration { @@ -32,18 +33,21 @@ impl Configuration { let store_sub = String::from(cfg.lookup_str("store").unwrap_or("/store")); let editor = cfg.lookup_str("editor").map(String::from); let editor_opts = String::from(cfg.lookup_str("editor-opts").unwrap_or("")); + let report_exit = cfg.lookup_boolean("report-exit").unwrap_or(false); debug!("Building configuration"); debug!(" - store sub : {}", store_sub); debug!(" - runtimepath: {}", rtp); debug!(" - editor : {:?}", editor); debug!(" - editor-opts: {}", editor_opts); + debug!(" - report exit: {}", report_exit); Configuration { store_sub: store_sub, rtp: rtp, editor: editor, editor_opts: editor_opts, + report_exit: report_exit, } } @@ -69,6 +73,10 @@ impl Configuration { self.editor_opts.clone() } + pub fn report_exit(&self) -> bool { + self.report_exit + } + } /** From d9de33a932a93498d8bf8c6aaa463acb3da13d75 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 6 Jan 2016 19:25:15 +0100 Subject: [PATCH 4/5] Add runtime wrapper for reporting mode --- src/runtime.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime.rs b/src/runtime.rs index 029e68a8..5eb3ddf7 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -135,6 +135,10 @@ impl<'a> Runtime<'a> { e } + pub fn report_exit(&self) -> bool { + self.config.report_exit() || self.configuration.report_exit() + } + } impl<'a> Debug for Runtime<'a> { From 51870b63f2afad866551010d74a0b0e1758a5956 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 6 Jan 2016 19:25:26 +0100 Subject: [PATCH 5/5] Add reporting implementation --- src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index 436435bc..5bb80a42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,4 +68,12 @@ fn main() { }; info!("{}", Yellow.paint(format!("Module execution ended with {}", res))); + + if rt.report_exit() { + if res { + println!("Ok"); + } else { + println!("Error"); + } + } }