- load config from json - cli commands to launch existing profiles - tui to pick custom directories and venv
39 lines
917 B
Rust
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)
|
|
}
|