Files
aare_launcher/src/launcher.rs
T
perl_d 2c98dd1c80 feat: basic functionality
- load config from json
- cli commands to launch existing profiles
- tui to pick custom directories and venv
2026-07-07 14:53:28 +02:00

39 lines
917 B
Rust

use std::path::Path;
use std::process::Command;
use anyhow::{Context, Result, bail};
use crate::config::LauncherEntry;
/// Run `python <entrypoint>` on the system, waiting for it to finish.
pub fn launch(python: &Path, entrypoint: &Path) -> Result<()> {
let status = Command::new(python)
.arg(entrypoint)
.status()
.with_context(|| {
format!(
"failed to launch {} {}",
python.display(),
entrypoint.display()
)
})?;
if !status.success() {
bail!(
"{} {} exited with {status}",
python.display(),
entrypoint.display()
);
}
Ok(())
}
pub fn launch_server(entry: &LauncherEntry) -> Result<()> {
launch(&entry.python, &entry.server_file)
}
pub fn launch_gui(entry: &LauncherEntry) -> Result<()> {
launch(&entry.python, &entry.gui_file)
}