use false as default instead of Option<bool>

master
rascul 2 years ago
parent 3480e0a62f
commit 16dc05992a

@ -19,13 +19,16 @@ pub struct App {
pub args: Option<Vec<String>>,
/// should the app be restarted if it exits successfully
pub restart_on_success: Option<bool>,
#[serde(default = "ret_false")]
pub restart_on_success: bool,
/// should the app be restarted if it exits unsuccessfully
pub restart_on_failure: Option<bool>,
#[serde(default = "ret_false")]
pub restart_on_failure: bool,
/// should the app be restarted if it is killed (SIGKILL)
pub restart_on_terminate: Option<bool>,
#[serde(default = "ret_false")]
pub restart_on_terminate: bool,
/// on sup startup, should we wait for this app to run before continuting
pub wait: Option<bool>,
@ -34,6 +37,10 @@ pub struct App {
pub hold: Option<bool>,
}
fn ret_false() -> bool {
false
}
impl App {
/// start the application and wait for it to exit
pub fn wait_start(&self) -> Result<()> {
@ -66,11 +73,11 @@ impl App {
/// see if the app should be restarted
pub fn check_restart(&self, status: ExitStatus) -> bool {
if status.success() {
self.restart_on_success.unwrap_or(false)
self.restart_on_success
} else if let Some(_code) = status.code() {
self.restart_on_failure.unwrap_or(false)
self.restart_on_failure
} else {
self.restart_on_terminate.unwrap_or(false)
self.restart_on_terminate
}
}
}

Loading…
Cancel
Save