aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: fc44fa536579dd36f0ab627ee35b561de2db8bde (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use pish::export_fun;
use std::io::{self, IsTerminal};

fn main() {
    export_fun::maybe_run_defined_function();
    if !io::stdin().is_terminal() {
        println!("need to run in a tty");
        return;
    }

    pish::panic::hook();

    // it is quite annoying when the terminal window closes due to a crash, so let's just catch all panics
    loop {
        let res = std::panic::catch_unwind(pish::event_loop);
        match res {
            Ok(_) => break,
            Err(_) => {
                #[cfg(debug_assertions)]
                unsafe {
                    pish::reload::continue_reload()
                }
            }
        }

        // prevent incredibly fast panic loops
        std::thread::sleep(std::time::Duration::from_secs(1));
    }

    println!("bye");
}