restructured auto-credentials (#74)

* restructured auto-credentials

* fix clone

---------

Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Geometrically <18202329+Geometrically@users.noreply.github.com>
This commit is contained in:
Wyatt Verchere
2023-04-07 14:43:21 -07:00
committed by GitHub
parent 34005dd2e2
commit 764d75181f
8 changed files with 82 additions and 48 deletions

View File

@@ -27,13 +27,13 @@ pub async fn profile_list(
Ok(res)
}
// Run Minecraft using a profile
// Run minecraft using a profile using the default credentials
// Returns a u32 representing the PID, which can be used to poll
// for the actual Child in the state.
// invoke('profile_run')
// invoke('profile_run', path)
#[tauri::command]
pub async fn profile_run(path: &Path, credentials: Credentials) -> Result<u32> {
let proc_lock = profile::run(path, &credentials).await?;
pub async fn profile_run(path: &Path) -> Result<u32> {
let proc_lock = profile::run(path).await?;
let pid = proc_lock.read().await.child.id().ok_or_else(|| {
theseus::Error::from(theseus::ErrorKind::LauncherError(
"Process failed to stay open.".to_string(),
@@ -42,14 +42,38 @@ pub async fn profile_run(path: &Path, credentials: Credentials) -> Result<u32> {
Ok(pid)
}
// Run Minecraft using a profile, and wait for the result
// invoke('profile_run_wait', path, credentials)
// Run Minecraft using a profile using the default credentials, and wait for the result
// invoke('profile_run_wait', path)
#[tauri::command]
pub async fn profile_run_wait(
path: &Path,
credentials: Credentials,
) -> Result<()> {
let proc_lock = profile::run(path, &credentials).await?;
pub async fn profile_run_wait(path: &Path) -> Result<()> {
let proc_lock = profile::run(path).await?;
let mut proc = proc_lock.write().await;
Ok(process::wait_for(&mut proc).await?)
}
// Run Minecraft using a profile using chosen credentials
// Returns a u32 representing the PID, which can be used to poll
// for the actual Child in the state.
// invoke('profile_run_credentials', {path, credentials})')
#[tauri::command]
pub async fn profile_run_credentials(path: &Path, credentials: Credentials) -> Result<u32> {
let proc_lock = profile::run_credentials(path, &credentials).await?;
let pid = proc_lock.read().await.child.id().ok_or_else(|| {
theseus::Error::from(theseus::ErrorKind::LauncherError(
"Process failed to stay open.".to_string(),
))
})?;
Ok(pid)
}
// Run Minecraft using a profile using the chosen credentials, and wait for the result
// invoke('profile_run_wait', {path, credentials)
#[tauri::command]
pub async fn profile_run_wait_credentials(
path: &Path,
credentials: Credentials,
) -> Result<()> {
let proc_lock = profile::run_credentials(path, &credentials).await?;
let mut proc = proc_lock.write().await;
Ok(process::wait_for(&mut proc).await?)
}