Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return exitcode #1220

Merged
merged 6 commits into from
Sep 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 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,25 @@ 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) -> ! {
let result = self.state().components().shutdown(self, shutdown);
if let Err(e) = result {
fatal_error(self, &e)
}

process::exit(exit_code);
}
}
Loading