summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-01-07 03:57:54 +0900
committerHomu <homu@barosl.com>2016-01-07 03:57:54 +0900
commit9662678b30d210500f4620a0ccc8330b8c97b25e (patch)
tree5fbde135b244a97e4b75e650ad49fb8affbfd467
parent19ef1dd25a1ff5fd4643142b8270e0ae12c9bcce (diff)
parent51870b63f2afad866551010d74a0b0e1758a5956 (diff)
Auto merge of #66 - matthiasbeyer:report-success, r=matthiasbeyer
Report success Report success (as simple "Ok"/"Error" string) to the user, if the user wants that.
-rw-r--r--etc/cli.yml5
-rw-r--r--src/cli.rs7
-rw-r--r--src/configuration.rs8
-rw-r--r--src/main.rs8
-rw-r--r--src/runtime.rs4
5 files changed, 32 insertions, 0 deletions
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
diff --git a/src/cli.rs b/src/cli.rs
index 6a75b5da..e422f565 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -43,6 +43,13 @@ impl<'a> CliConfig<'a> {
}
/**
+ * 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
*/
pub fn get_rtp(&self) -> Option<String> {
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<String>,
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
+ }
+
}
/**
diff --git a/src/main.rs b/src/main.rs
index 2b275895..08d2ffcf 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -69,4 +69,12 @@ fn main() {
};
info!("{}", Yellow.paint(format!("Module execution ended with {}", res)));
+
+ if rt.report_exit() {
+ if res {
+ println!("Ok");
+ } else {
+ println!("Error");
+ }
+ }
}
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> {