2024-12-01 20:50:11 -05:00
|
|
|
use anyhow::Result;
|
2024-12-02 11:51:39 -06:00
|
|
|
use clap::Parser;
|
|
|
|
use log::{info, warn, LevelFilter};
|
2024-12-01 16:02:06 -05:00
|
|
|
|
|
|
|
pub mod core;
|
2024-12-02 11:51:39 -06:00
|
|
|
pub mod utils;
|
2024-12-01 16:02:06 -05:00
|
|
|
|
2024-12-02 11:51:39 -06:00
|
|
|
use utils::{logger::LOGGER, splash::print_splash};
|
|
|
|
|
|
|
|
#[derive(Parser)]
|
|
|
|
struct Cli {
|
|
|
|
#[arg(long, short, help = "Enable logging output")]
|
|
|
|
log: bool,
|
2024-12-01 23:52:12 -06:00
|
|
|
}
|
|
|
|
|
2024-12-01 16:02:06 -05:00
|
|
|
#[tokio::main]
|
2024-12-01 20:50:11 -05:00
|
|
|
async fn main() -> Result<()> {
|
2024-12-02 11:51:39 -06:00
|
|
|
let cli = Cli::parse();
|
|
|
|
|
|
|
|
log::set_logger(&*LOGGER).unwrap();
|
|
|
|
log::set_max_level(LevelFilter::Debug);
|
2024-12-01 16:02:06 -05:00
|
|
|
|
2024-12-01 23:52:12 -06:00
|
|
|
print_splash();
|
2024-12-02 11:51:39 -06:00
|
|
|
|
|
|
|
if cli.log {
|
|
|
|
info!("Initializing Engine with logging to stdout enabled");
|
|
|
|
warn!("REPL cannot be used with logging enabled due to ReedLine not supporting writing to stdout");
|
|
|
|
|
|
|
|
core::init_renderer()?;
|
|
|
|
} else {
|
|
|
|
LOGGER.write_to_stdout();
|
|
|
|
info!("Initializing Engine with logging to stdout disabled");
|
|
|
|
warn!("REPL cannot be used with logging enabled due to ReedLine not supporting writing to stdout");
|
|
|
|
info!("Writing all logs to file z.log");
|
|
|
|
|
|
|
|
LOGGER.write_to_file("z.log");
|
|
|
|
info!("Logging back to file z.log");
|
|
|
|
|
|
|
|
let shell_thread = tokio::task::spawn(async {
|
|
|
|
core::repl::repl::handle_repl().await;
|
|
|
|
});
|
|
|
|
|
|
|
|
core::init_renderer()?;
|
|
|
|
shell_thread.await?;
|
|
|
|
}
|
|
|
|
|
2024-12-01 16:02:06 -05:00
|
|
|
Ok(())
|
|
|
|
}
|