Folder names (#318)

This commit is contained in:
Wyatt Verchere
2023-07-21 20:16:07 -07:00
committed by GitHub
parent 4941260805
commit 3fa33dc241
42 changed files with 1129 additions and 535 deletions

View File

@@ -36,8 +36,8 @@ pub fn init<R: tauri::Runtime>() -> tauri::plugin::TauriPlugin<R> {
// Remove a profile
// invoke('plugin:profile|profile_add_path',path)
#[tauri::command]
pub async fn profile_remove(path: &Path) -> Result<()> {
profile::remove(path).await?;
pub async fn profile_remove(path: ProfilePathId) -> Result<()> {
profile::remove(&path).await?;
Ok(())
}
@@ -45,19 +45,19 @@ pub async fn profile_remove(path: &Path) -> Result<()> {
// invoke('plugin:profile|profile_add_path',path)
#[tauri::command]
pub async fn profile_get(
path: &Path,
path: ProfilePathId,
clear_projects: Option<bool>,
) -> Result<Option<Profile>> {
let res = profile::get(path, clear_projects).await?;
let res = profile::get(&path, clear_projects).await?;
Ok(res)
}
// Get optimal java version from profile
#[tauri::command]
pub async fn profile_get_optimal_jre_key(
path: &Path,
path: ProfilePathId,
) -> Result<Option<JavaVersion>> {
let res = profile::get_optimal_jre_key(path).await?;
let res = profile::get_optimal_jre_key(&path).await?;
Ok(res)
}
@@ -66,14 +66,14 @@ pub async fn profile_get_optimal_jre_key(
#[tauri::command]
pub async fn profile_list(
clear_projects: Option<bool>,
) -> Result<HashMap<PathBuf, Profile>> {
) -> Result<HashMap<ProfilePathId, Profile>> {
let res = profile::list(clear_projects).await?;
Ok(res)
}
#[tauri::command]
pub async fn profile_check_installed(
path: &Path,
path: ProfilePathId,
project_id: String,
) -> Result<bool> {
let profile = profile_get(path, None).await?;
@@ -94,8 +94,8 @@ pub async fn profile_check_installed(
/// Installs/Repairs a profile
/// invoke('plugin:profile|profile_install')
#[tauri::command]
pub async fn profile_install(path: &Path) -> Result<()> {
profile::install(path).await?;
pub async fn profile_install(path: ProfilePathId) -> Result<()> {
profile::install(&path).await?;
Ok(())
}
@@ -103,40 +103,40 @@ pub async fn profile_install(path: &Path) -> Result<()> {
/// invoke('plugin:profile|profile_update_all')
#[tauri::command]
pub async fn profile_update_all(
path: &Path,
) -> Result<HashMap<PathBuf, PathBuf>> {
Ok(profile::update_all(path).await?)
path: ProfilePathId,
) -> Result<HashMap<ProjectPathId, ProjectPathId>> {
Ok(profile::update_all(&path).await?)
}
/// Updates a specified project
/// invoke('plugin:profile|profile_update_project')
#[tauri::command]
pub async fn profile_update_project(
path: &Path,
project_path: &Path,
) -> Result<PathBuf> {
Ok(profile::update_project(path, project_path, None).await?)
path: ProfilePathId,
project_path: ProjectPathId,
) -> Result<ProjectPathId> {
Ok(profile::update_project(&path, &project_path, None).await?)
}
// Adds a project to a profile from a version ID
// invoke('plugin:profile|profile_add_project_from_version')
#[tauri::command]
pub async fn profile_add_project_from_version(
path: &Path,
path: ProfilePathId,
version_id: String,
) -> Result<PathBuf> {
Ok(profile::add_project_from_version(path, version_id).await?)
) -> Result<ProjectPathId> {
Ok(profile::add_project_from_version(&path, version_id).await?)
}
// Adds a project to a profile from a path
// invoke('plugin:profile|profile_add_project_from_path')
#[tauri::command]
pub async fn profile_add_project_from_path(
path: &Path,
path: ProfilePathId,
project_path: &Path,
project_type: Option<String>,
) -> Result<PathBuf> {
let res = profile::add_project_from_path(path, project_path, project_type)
) -> Result<ProjectPathId> {
let res = profile::add_project_from_path(&path, project_path, project_type)
.await?;
Ok(res)
}
@@ -145,20 +145,20 @@ pub async fn profile_add_project_from_path(
// invoke('plugin:profile|profile_toggle_disable_project')
#[tauri::command]
pub async fn profile_toggle_disable_project(
path: &Path,
project_path: &Path,
) -> Result<PathBuf> {
Ok(profile::toggle_disable_project(path, project_path).await?)
path: ProfilePathId,
project_path: ProjectPathId,
) -> Result<ProjectPathId> {
Ok(profile::toggle_disable_project(&path, &project_path).await?)
}
// Removes a project from a profile
// invoke('plugin:profile|profile_remove_project')
#[tauri::command]
pub async fn profile_remove_project(
path: &Path,
project_path: &Path,
path: ProfilePathId,
project_path: ProjectPathId,
) -> Result<()> {
profile::remove_project(path, project_path).await?;
profile::remove_project(&path, &project_path).await?;
Ok(())
}
@@ -166,13 +166,13 @@ pub async fn profile_remove_project(
// invoke('profile_export_mrpack')
#[tauri::command]
pub async fn profile_export_mrpack(
path: &Path,
path: ProfilePathId,
export_location: PathBuf,
included_overrides: Vec<String>,
version_id: Option<String>,
) -> Result<()> {
profile::export_mrpack(
path,
&path,
export_location,
included_overrides,
version_id,
@@ -190,7 +190,7 @@ pub async fn profile_export_mrpack(
// => [folder1, folder2]
#[tauri::command]
pub async fn profile_get_potential_override_folders(
profile_path: PathBuf,
profile_path: ProfilePathId,
) -> Result<Vec<PathBuf>> {
let overrides =
profile::get_potential_override_folders(profile_path).await?;
@@ -202,8 +202,8 @@ pub async fn profile_get_potential_override_folders(
// for the actual Child in the state.
// invoke('plugin:profile|profile_run', path)
#[tauri::command]
pub async fn profile_run(path: &Path) -> Result<Uuid> {
let minecraft_child = profile::run(path).await?;
pub async fn profile_run(path: ProfilePathId) -> Result<Uuid> {
let minecraft_child = profile::run(&path).await?;
let uuid = minecraft_child.read().await.uuid;
Ok(uuid)
}
@@ -211,8 +211,8 @@ pub async fn profile_run(path: &Path) -> Result<Uuid> {
// Run Minecraft using a profile using the default credentials, and wait for the result
// invoke('plugin:profile|profile_run_wait', path)
#[tauri::command]
pub async fn profile_run_wait(path: &Path) -> Result<()> {
let proc_lock = profile::run(path).await?;
pub async fn profile_run_wait(path: ProfilePathId) -> Result<()> {
let proc_lock = profile::run(&path).await?;
let mut proc = proc_lock.write().await;
Ok(process::wait_for(&mut proc).await?)
}
@@ -223,11 +223,12 @@ pub async fn profile_run_wait(path: &Path) -> Result<()> {
// invoke('plugin:profile|profile_run_credentials', {path, credentials})')
#[tauri::command]
pub async fn profile_run_credentials(
path: &Path,
path: ProfilePathId,
credentials: Credentials,
) -> Result<Uuid> {
let minecraft_child = profile::run_credentials(path, &credentials).await?;
let minecraft_child = profile::run_credentials(&path, &credentials).await?;
let uuid = minecraft_child.read().await.uuid;
Ok(uuid)
}
@@ -235,10 +236,10 @@ pub async fn profile_run_credentials(
// invoke('plugin:profile|profile_run_wait', {path, credentials)
#[tauri::command]
pub async fn profile_run_wait_credentials(
path: &Path,
path: ProfilePathId,
credentials: Credentials,
) -> Result<()> {
let proc_lock = profile::run_credentials(path, &credentials).await?;
let proc_lock = profile::run_credentials(&path, &credentials).await?;
let mut proc = proc_lock.write().await;
Ok(process::wait_for(&mut proc).await?)
}
@@ -265,10 +266,10 @@ pub struct EditProfileMetadata {
// invoke('plugin:profile|profile_edit', {path, editProfile})
#[tauri::command]
pub async fn profile_edit(
path: &Path,
path: ProfilePathId,
edit_profile: EditProfile,
) -> Result<()> {
profile::edit(path, |prof| {
profile::edit(&path, |prof| {
if let Some(metadata) = edit_profile.metadata.clone() {
if let Some(name) = metadata.name {
prof.metadata.name = name;
@@ -305,9 +306,9 @@ pub async fn profile_edit(
// invoke('plugin:profile|profile_edit_icon')
#[tauri::command]
pub async fn profile_edit_icon(
path: &Path,
path: ProfilePathId,
icon_path: Option<&Path>,
) -> Result<()> {
profile::edit_icon(path, icon_path).await?;
profile::edit_icon(&path, icon_path).await?;
Ok(())
}