Skip to content

Commit

Permalink
fix: return exitcode
Browse files Browse the repository at this point in the history
  • Loading branch information
aawsome committed Sep 2, 2024
1 parent 4885724 commit b9e2263
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/application.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
}

0 comments on commit b9e2263

Please sign in to comment.