From b9e2263e0395a9b961b6f68269d2356620ed16bb Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Mon, 2 Sep 2024 06:59:47 +0200 Subject: [PATCH 1/3] fix: return exitcode --- src/application.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/application.rs b/src/application.rs index 63513b618..40c42701c 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,11 +1,11 @@ //! Rustic Abscissa Application -use std::env; +use std::{env, process}; use abscissa_core::{ - application::{self, AppCell}, + application::{self, fatal_error, AppCell}, config::{self, CfgCell}, terminal::component::Terminal, - Application, Component, FrameworkError, StandardPaths, + Application, Component, FrameworkError, Shutdown, StandardPaths, }; use anyhow::Result; @@ -99,4 +99,24 @@ impl Application for RusticApp { Ok(()) } + + /// Shut down this application gracefully + fn shutdown(&self, shutdown: Shutdown) -> ! { + let exit_code = match shutdown { + Shutdown::Crash => 1, + _ => 0, + }; + self.shutdown_with_exitcode(shutdown, exit_code) + } +} + +impl RusticApp { + /// Shut down this application gracefully, exiting with given exit code. + fn shutdown_with_exitcode(&self, shutdown: Shutdown, exit_code: i32) -> ! { + if let Err(e) = self.state().components().shutdown(self, shutdown) { + fatal_error(self, &e) + } + + process::exit(exit_code); + } } From 3326de35dfe692cd1a808ccc07d1ad15ec744fd7 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 6 Sep 2024 21:31:31 +0200 Subject: [PATCH 2/3] fix clippy --- src/application.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/application.rs b/src/application.rs index 40c42701c..4799a8395 100644 --- a/src/application.rs +++ b/src/application.rs @@ -113,7 +113,8 @@ impl Application for RusticApp { impl RusticApp { /// Shut down this application gracefully, exiting with given exit code. fn shutdown_with_exitcode(&self, shutdown: Shutdown, exit_code: i32) -> ! { - if let Err(e) = self.state().components().shutdown(self, shutdown) { + let result = self.state().components().shutdown(self, shutdown) { + if let Err(e) = result fatal_error(self, &e) } From d991366dd0013ddc8be1c3d8185bd7f2658f8111 Mon Sep 17 00:00:00 2001 From: Alexander Weiss Date: Fri, 6 Sep 2024 21:44:12 +0200 Subject: [PATCH 3/3] fix source code --- src/application.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application.rs b/src/application.rs index 4799a8395..60a90cdd0 100644 --- a/src/application.rs +++ b/src/application.rs @@ -113,8 +113,8 @@ impl Application for RusticApp { impl RusticApp { /// Shut down this application gracefully, exiting with given exit code. fn shutdown_with_exitcode(&self, shutdown: Shutdown, exit_code: i32) -> ! { - let result = self.state().components().shutdown(self, shutdown) { - if let Err(e) = result + let result = self.state().components().shutdown(self, shutdown); + if let Err(e) = result { fatal_error(self, &e) }