used cli for prometeu runtime
This commit is contained in:
parent
0b2a97aa88
commit
28df72417b
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1937,6 +1937,7 @@ dependencies = [
|
|||||||
name = "prometeu-runtime-desktop"
|
name = "prometeu-runtime-desktop"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"clap",
|
||||||
"cpal",
|
"cpal",
|
||||||
"pixels",
|
"pixels",
|
||||||
"prometeu-core",
|
"prometeu-core",
|
||||||
|
|||||||
@ -19,4 +19,5 @@ winit = "0.30.12"
|
|||||||
pixels = "0.15.0"
|
pixels = "0.15.0"
|
||||||
cpal = "0.15.3"
|
cpal = "0.15.3"
|
||||||
ringbuf = "0.4.7"
|
ringbuf = "0.4.7"
|
||||||
serde_json = "1.0.149"
|
serde_json = "1.0.149"
|
||||||
|
clap = { version = "4.5", features = ["derive"] }
|
||||||
@ -12,62 +12,49 @@ use runner::HostRunner;
|
|||||||
use cap::load_cap_config;
|
use cap::load_cap_config;
|
||||||
use winit::event_loop::EventLoop;
|
use winit::event_loop::EventLoop;
|
||||||
use prometeu_core::firmware::BootTarget;
|
use prometeu_core::firmware::BootTarget;
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[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>> {
|
pub fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let args: Vec<String> = std::env::args().collect();
|
let cli = Cli::parse();
|
||||||
let mut fs_root = None;
|
|
||||||
let mut cap_config = None;
|
|
||||||
let mut cartridge_path = None;
|
|
||||||
let mut debug_mode = false;
|
|
||||||
let mut debug_port = 7777;
|
|
||||||
|
|
||||||
let mut i = 1; // Skip the executable name
|
let fs_root = cli.fs_root;
|
||||||
while i < args.len() {
|
let cap_config = cli.cap.as_ref().and_then(|path| load_cap_config(path));
|
||||||
match args[i].as_str() {
|
|
||||||
"--run" => {
|
|
||||||
if i + 1 < args.len() {
|
|
||||||
cartridge_path = Some(args[i + 1].clone());
|
|
||||||
debug_mode = false;
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"--debug" => {
|
|
||||||
if i + 1 < args.len() {
|
|
||||||
cartridge_path = Some(args[i + 1].clone());
|
|
||||||
debug_mode = true;
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"--port" => {
|
|
||||||
if i + 1 < args.len() {
|
|
||||||
if let Ok(port) = args[i + 1].parse::<u16>() {
|
|
||||||
debug_port = port;
|
|
||||||
}
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"--fs-root" => {
|
|
||||||
if i + 1 < args.len() {
|
|
||||||
fs_root = Some(args[i + 1].clone());
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
"--cap" => {
|
|
||||||
if i + 1 < args.len() {
|
|
||||||
cap_config = load_cap_config(&args[i + 1]);
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
i += 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
let boot_target = if let Some(path) = cartridge_path {
|
let boot_target = if let Some(path) = cli.debug {
|
||||||
BootTarget::Cartridge {
|
BootTarget::Cartridge {
|
||||||
path,
|
path,
|
||||||
debug: debug_mode,
|
debug: true,
|
||||||
debug_port: if debug_mode { debug_port } else { 7777 },
|
debug_port: cli.port,
|
||||||
|
}
|
||||||
|
} else if let Some(path) = cli.run {
|
||||||
|
BootTarget::Cartridge {
|
||||||
|
path,
|
||||||
|
debug: false,
|
||||||
|
debug_port: 7777,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
BootTarget::Hub
|
BootTarget::Hub
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user