diff --git a/systeroid-tui/src/main.rs b/systeroid-tui/src/main.rs index 55a1dcd..1ddd6b6 100644 --- a/systeroid-tui/src/main.rs +++ b/systeroid-tui/src/main.rs @@ -11,11 +11,9 @@ use termion::screen::IntoAlternateScreen; fn main() -> Result<()> { if let Some(args) = Args::parse(env::args().collect()) { - let output = io::stderr(); - let output = output.into_raw_mode()?; - let output = MouseTerminal::from(output); - let output = output.into_alternate_screen()?; - let backend = TermionBackend::new(output); + let raw_output = io::stderr().into_raw_mode()?; + raw_output.suspend_raw_mode()?; + let panic_hook = panic::take_hook(); panic::set_hook(Box::new(move |panic| { let panic_cleanup = || -> Result<()> { @@ -27,13 +25,20 @@ fn main() -> Result<()> { termion::screen::ToMainScreen, termion::cursor::Show )?; - output.into_raw_mode()?.suspend_raw_mode()?; - io::stderr().flush()?; + raw_output.suspend_raw_mode()?; + output.flush()?; Ok(()) }; - panic_cleanup().expect("failed to clean up for panic"); + + panic_cleanup().expect("Failed to cleanup after panic"); panic_hook(panic); })); + let output = io::stderr(); + let output = output.into_raw_mode()?; + let output = MouseTerminal::from(output); + let output = output.into_alternate_screen()?; + let backend = TermionBackend::new(output); + match systeroid_tui::run(args, backend) { Ok(_) => process::exit(0), Err(e) => {