2026-03-24 13:40:35 +00:00

64 lines
1.6 KiB
Rust

pub mod audio;
pub mod cap;
pub mod debugger;
pub mod fs_backend;
pub mod input;
pub mod log_sink;
pub mod runner;
pub mod stats;
pub mod utilities;
use cap::load_cap_config;
use clap::Parser;
use prometeu_firmware::BootTarget;
use runner::HostRunner;
use winit::event_loop::EventLoop;
#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Cli {
/// Run a cartridge
#[arg(long, value_name = "PATH", conflicts_with = "debug")]
run: Option<String>,
/// Debug a cartridge
#[arg(long, value_name = "PATH", conflicts_with = "run")]
debug: Option<String>,
/// Port for the debugger
#[arg(long, default_value_t = 7777)]
port: u16,
/// Root directory for the filesystem
#[arg(long, value_name = "PATH")]
fs_root: Option<String>,
/// Path to the capability configuration file
#[arg(long, value_name = "PATH")]
cap: Option<String>,
}
pub fn run() -> Result<(), Box<dyn std::error::Error>> {
let cli = Cli::parse();
let fs_root = cli.fs_root;
let cap_config = cli.cap.as_ref().and_then(|path| load_cap_config(path));
let boot_target = if let Some(path) = cli.debug {
BootTarget::Cartridge { path, debug: true, debug_port: cli.port }
} else if let Some(path) = cli.run {
BootTarget::Cartridge { path, debug: false, debug_port: 7777 }
} else {
BootTarget::Hub
};
let event_loop = EventLoop::new()?;
let mut runner = HostRunner::new(fs_root, cap_config);
runner.set_boot_target(boot_target);
event_loop.run_app(&mut runner)?;
Ok(())
}