//! Library entry point. `main.rs` calls `run()`.

mod commands;
mod pty;

use crate::pty::PtyManager;

pub fn run() {
    let _ = tracing_subscriber::fmt()
        .with_env_filter(
            tracing_subscriber::EnvFilter::try_from_default_env()
                .unwrap_or_else(|_| tracing_subscriber::EnvFilter::new("info")),
        )
        .with_writer(std::io::stderr)
        .try_init();

    tauri::Builder::default()
        .manage(PtyManager::new())
        .invoke_handler(tauri::generate_handler![
            commands::list_distros,
            commands::spawn_pane,
            commands::write_to_pane,
            commands::resize_pane,
            commands::kill_pane,
            commands::save_workspace,
            commands::load_workspace,
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
