use core::{panic::set_panic_hook, repl::setup, splash}; use thiserror::Error; use colored::Colorize; use tokio::runtime; #[allow(unused_imports)] use tracing::{debug, error, info, warn}; use tracing::{level_filters::LevelFilter, subscriber::set_global_default}; use winit::event_loop::EventLoop; pub mod core; pub mod error; pub mod metadata; fn init_logger() { let subscriber = tracing_subscriber::fmt() .with_max_level(LevelFilter::DEBUG) .with_level(true) .compact() .pretty() .log_internal_errors(false) .without_time() .with_thread_names(true) .finish(); set_global_default(subscriber).expect("Failed to set default subscriber"); } #[tokio::main(flavor = "current_thread")] async fn main() { init_logger(); let sysinfo = crate::metadata::SystemMetadata::current(); set_panic_hook(); setup(); splash::print_splash(); if !cfg!(debug_assertions) { info!("{}", "Debug mode disabled".bright_blue()); set_panic_hook(); } else { println!("{}",sysinfo.verbose_summary()); } info!("Type 'help' for a list of commands."); let repl_thread = std::thread::spawn(|| { let rt = match runtime::Builder::new_current_thread() .enable_all() .build() { Ok(rt) => rt, Err(e) => { error!("A fatal error has occured: {e}"); std::process::exit(1) }, }; rt.block_on(core::repl::input::handle_repl()) }); splash::print_splash(); info!("Type 'help' for a list of commands."); match EventLoop::new() { Ok(event_loop) => { core::render::init_renderer(event_loop); } Err(e) => { error!("{e}") } }; if let Err(_) = repl_thread.join() { error!("REPL thread panicked"); } }