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.
This commit is contained in:
commit
9662678b30
5 changed files with 32 additions and 0 deletions
|
@ -15,6 +15,11 @@ args:
|
||||||
help: Sets the level of debugging information
|
help: Sets the level of debugging information
|
||||||
required: false
|
required: false
|
||||||
|
|
||||||
|
- report:
|
||||||
|
long: report
|
||||||
|
help: Print "Ok" on success, "Error" on failure (except hard errors) before exiting, regardless of verbosity
|
||||||
|
required: false
|
||||||
|
|
||||||
- rtp:
|
- rtp:
|
||||||
short: r
|
short: r
|
||||||
long: runtimepath
|
long: runtimepath
|
||||||
|
|
|
@ -42,6 +42,13 @@ impl<'a> CliConfig<'a> {
|
||||||
self.cli_matches.is_present("debug")
|
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
|
* Get the runtime path the CLI configured
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub struct Configuration {
|
||||||
pub store_sub : String,
|
pub store_sub : String,
|
||||||
pub editor : Option<String>,
|
pub editor : Option<String>,
|
||||||
pub editor_opts : String,
|
pub editor_opts : String,
|
||||||
|
pub report_exit : bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Configuration {
|
impl Configuration {
|
||||||
|
@ -32,18 +33,21 @@ impl Configuration {
|
||||||
let store_sub = String::from(cfg.lookup_str("store").unwrap_or("/store"));
|
let store_sub = String::from(cfg.lookup_str("store").unwrap_or("/store"));
|
||||||
let editor = cfg.lookup_str("editor").map(String::from);
|
let editor = cfg.lookup_str("editor").map(String::from);
|
||||||
let editor_opts = String::from(cfg.lookup_str("editor-opts").unwrap_or(""));
|
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!("Building configuration");
|
||||||
debug!(" - store sub : {}", store_sub);
|
debug!(" - store sub : {}", store_sub);
|
||||||
debug!(" - runtimepath: {}", rtp);
|
debug!(" - runtimepath: {}", rtp);
|
||||||
debug!(" - editor : {:?}", editor);
|
debug!(" - editor : {:?}", editor);
|
||||||
debug!(" - editor-opts: {}", editor_opts);
|
debug!(" - editor-opts: {}", editor_opts);
|
||||||
|
debug!(" - report exit: {}", report_exit);
|
||||||
|
|
||||||
Configuration {
|
Configuration {
|
||||||
store_sub: store_sub,
|
store_sub: store_sub,
|
||||||
rtp: rtp,
|
rtp: rtp,
|
||||||
editor: editor,
|
editor: editor,
|
||||||
editor_opts: editor_opts,
|
editor_opts: editor_opts,
|
||||||
|
report_exit: report_exit,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +73,10 @@ impl Configuration {
|
||||||
self.editor_opts.clone()
|
self.editor_opts.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn report_exit(&self) -> bool {
|
||||||
|
self.report_exit
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,4 +69,12 @@ fn main() {
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("{}", Yellow.paint(format!("Module execution ended with {}", res)));
|
info!("{}", Yellow.paint(format!("Module execution ended with {}", res)));
|
||||||
|
|
||||||
|
if rt.report_exit() {
|
||||||
|
if res {
|
||||||
|
println!("Ok");
|
||||||
|
} else {
|
||||||
|
println!("Error");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,10 @@ impl<'a> Runtime<'a> {
|
||||||
e
|
e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn report_exit(&self) -> bool {
|
||||||
|
self.config.report_exit() || self.configuration.report_exit()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Debug for Runtime<'a> {
|
impl<'a> Debug for Runtime<'a> {
|
||||||
|
|
Loading…
Reference in a new issue