added domains into crates

This commit is contained in:
2026-03-24 13:40:34 +00:00
parent 1135514508
commit bddd588464
222 changed files with 751 additions and 790 deletions
+31
View File
@@ -0,0 +1,31 @@
[package]
name = "prometeu-cli"
version = "0.1.0"
edition = "2024"
license.workspace = true
repository.workspace = true
[[bin]]
name = "prometeu"
path = "src/main.rs"
[[bin]]
name = "prometeu-runtime"
path = "src/bin/prometeu-runtime.rs"
[[bin]]
name = "prometeuc"
path = "src/bin/prometeuc.rs"
[package.metadata.dist]
dist = true
include = [
"../../../VERSION.txt",
"../../../dist-staging/devtools/debugger-protocol"
]
[dependencies]
clap = { version = "4.5", features = ["derive"] }
prometeu-host-desktop-winit = { path = "../../host/prometeu-host-desktop-winit" }
prometeu-compiler = { path = "../../compiler/prometeu-compiler" }
anyhow = "1.0.100"
+16
View File
@@ -0,0 +1,16 @@
# PROMETEU CLI (Dispatcher)
The `prometeu` binary acts as the unified front-end for the ecosystem. It does not implement the execution or compilation logic but knows where to find the binaries that do.
## Commands
- `prometeu run <cart>`: Runs a cartridge using the available runtime.
- `prometeu debug <cart> [--port <p>]`: Starts execution in debug mode.
- `prometeu build <projectDir>`: Calls the `prometeuc` compiler.
- `prometeu verify c <projectDir>`: Calls the `prometeuc` compiler.
- `prometeu pack <cartDir>`: (Planned) Calls the `prometeup` packager.
- `prometeu verify p <cartDir>`: (Planned) Calls the `prometeup` packager.
## How it works
The dispatcher locates sibling binaries (`prometeu-host-desktop-winit`, `prometeuc`, etc.) in the same directory where it is installed. It inherits `stdin`, `stdout`, and `stderr`, and propagates the exit code of the called process.
@@ -0,0 +1 @@
fn main() -> Result<(), Box<dyn std::error::Error>> { prometeu_host_desktop_winit::run() }
@@ -0,0 +1 @@
fn main() -> anyhow::Result<()> { prometeu_compiler::run() }
+176
View File
@@ -0,0 +1,176 @@
use clap::{Parser, Subcommand};
use std::env;
use std::path::{Path, PathBuf};
use std::process::Command;
/// PROMETEU Dispatcher (CLI).
///
/// The main entry point for the user. This binary does not implement
/// compilation or execution logic itself; instead, it acts as a smart
/// front-end that locates and dispatches commands to specialized
/// components like `prometeu-host-desktop-winit` or `prometeu-compiler`.
#[derive(Parser)]
#[command(name = "prometeu")]
#[command(about = "Dispatcher for the Prometeu ecosystem", long_about = None)]
struct Cli {
#[command(subcommand)]
command: Option<Commands>,
}
#[derive(Subcommand)]
enum Commands {
/// Executes a cartridge using the available runtime.
Run {
/// Path to the cartridge (directory or .pmc file).
cart: String,
},
/// Executes a cartridge in Assisted Mode (Debug).
/// The runtime will wait for a DevTools connection before starting.
Debug {
/// Path to the cartridge.
cart: String,
/// TCP port for the DevTools server (default: 7777).
#[arg(long, default_value_t = 7777)]
port: u16,
},
/// Compiles a source project into a cartridge (PBC).
Build {
/// Project source directory.
project_dir: String,
/// Whether to explain the dependency resolution process.
#[arg(long)]
explain_deps: bool,
},
/// Packages a cartridge directory into a distributable .pmc file.
Pack {
/// Cartridge directory.
cart_dir: String,
},
/// Diagnostic commands to verify project or cartridge integrity.
Verify {
#[command(subcommand)]
target: VerifyCommands,
},
}
#[derive(Subcommand)]
enum VerifyCommands {
/// Verifies a project
C {
/// Project directory
project_dir: String,
/// Whether to explain the dependency resolution process.
#[arg(long)]
explain_deps: bool,
},
/// Verifies a cartridge or PMC file
P {
/// Path to the cartridge or PMC
cart_or_pmc: String,
},
}
fn main() {
let cli = Cli::parse();
let exe_dir = match env::current_exe() {
Ok(exe_path) => exe_path.parent().unwrap_or_else(|| Path::new("../../../..")).to_path_buf(),
Err(e) => {
eprintln!("Error obtaining executable path: {}", e);
std::process::exit(1);
}
};
match cli.command {
Some(Commands::Run { cart }) => {
dispatch(&exe_dir, "prometeu-runtime", &["--run", &cart]);
}
Some(Commands::Debug { cart, port }) => {
dispatch(
&exe_dir,
"prometeu-runtime",
&["--debug", &cart, "--port", &port.to_string()],
);
}
Some(Commands::Build { project_dir, explain_deps }) => {
let mut args = vec!["build", &project_dir];
if explain_deps {
args.push("--explain-deps");
}
dispatch(&exe_dir, "prometeuc", &args);
}
Some(Commands::Pack { .. }) => {
not_implemented("pack", "prometeup");
}
Some(Commands::Verify { target }) => match target {
VerifyCommands::C { project_dir, explain_deps } => {
let mut args = vec!["verify", &project_dir];
if explain_deps {
args.push("--explain-deps");
}
dispatch(&exe_dir, "prometeuc", &args);
}
VerifyCommands::P { .. } => not_implemented("verify p", "prometeup"),
},
None => {
use clap::CommandFactory;
Cli::command().print_help().unwrap();
println!();
}
}
}
fn get_binary_path(dir: &Path, name: &str) -> PathBuf {
let mut path = dir.join(name);
if cfg!(target_os = "windows") {
path.set_extension("exe");
}
path
}
fn dispatch(exe_dir: &Path, bin_name: &str, args: &[&str]) {
let bin_path = get_binary_path(exe_dir, bin_name);
if !bin_path.exists() {
eprintln!(
"prometeu: command '{}' is not yet available in this distribution on {}",
match bin_name {
"prometeu-runtime" => "run/debug",
"prometeuc" => "build/verify c",
"prometeup" => "pack/verify p",
_ => bin_name,
}, exe_dir.display()
);
std::process::exit(1);
}
execute_bin(&bin_path, args);
}
fn execute_bin(bin_path: &Path, args: &[&str]) {
let status = Command::new(bin_path)
.args(args)
.stdin(std::process::Stdio::inherit())
.stdout(std::process::Stdio::inherit())
.stderr(std::process::Stdio::inherit())
.status();
match status {
Ok(status) => {
std::process::exit(status.code().unwrap_or(0));
}
Err(e) => {
eprintln!("Error executing {}: {}", bin_path.display(), e);
std::process::exit(1);
}
}
}
fn not_implemented(cmd: &str, _bin_name: &str) {
eprintln!(
"prometeu: command '{}' is not yet available in this distribution",
cmd
);
std::process::exit(1);
}