2021-07-09 20:05:04 -07:00
|
|
|
//! # Theseus
|
|
|
|
|
//!
|
|
|
|
|
//! Theseus is a library which provides utilities for launching minecraft, creating Modrinth mod packs,
|
|
|
|
|
//! and launching Modrinth mod packs
|
|
|
|
|
|
2022-03-28 18:41:35 -07:00
|
|
|
#![warn(unused_import_braces, missing_debug_implementations)]
|
2021-06-29 22:32:52 -07:00
|
|
|
|
2022-04-10 13:14:53 -07:00
|
|
|
// TODO: make non-hardcoded
|
|
|
|
|
lazy_static::lazy_static! {
|
|
|
|
|
static ref LAUNCHER_WORK_DIR: std::path::PathBuf = dirs::config_dir().expect("Could not find config dir").join("theseus");
|
|
|
|
|
}
|
2021-12-15 22:24:08 -07:00
|
|
|
|
2022-03-28 18:41:35 -07:00
|
|
|
pub mod data;
|
2021-06-29 22:32:52 -07:00
|
|
|
pub mod launcher;
|
2021-11-17 20:34:21 -08:00
|
|
|
pub mod modpack;
|
2021-11-10 21:52:55 -07:00
|
|
|
mod util;
|
2021-12-15 22:24:08 -07:00
|
|
|
|
|
|
|
|
#[derive(thiserror::Error, Debug)]
|
|
|
|
|
pub enum Error {
|
|
|
|
|
#[error("Launcher error: {0}")]
|
|
|
|
|
LauncherError(#[from] launcher::LauncherError),
|
|
|
|
|
|
|
|
|
|
#[error("Modpack error: {0}")]
|
|
|
|
|
ModpackError(#[from] modpack::ModpackError),
|
|
|
|
|
|
2021-12-19 22:48:50 -07:00
|
|
|
#[error("Data error: {0}")]
|
|
|
|
|
DaedalusError(#[from] data::DataError),
|
2021-12-15 22:24:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn init() -> Result<(), Error> {
|
2022-04-10 13:14:53 -07:00
|
|
|
tokio::fs::create_dir_all(LAUNCHER_WORK_DIR.as_path())
|
|
|
|
|
.await
|
2022-03-28 18:41:35 -07:00
|
|
|
.expect("Unable to create launcher root directory!");
|
|
|
|
|
|
|
|
|
|
use crate::data::*;
|
|
|
|
|
Metadata::init().await?;
|
|
|
|
|
|
|
|
|
|
Settings::init().await?;
|
|
|
|
|
|
|
|
|
|
tokio::try_join! {
|
|
|
|
|
launcher::init_download_semaphore(),
|
|
|
|
|
Profiles::init(),
|
|
|
|
|
}?;
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn save() -> Result<(), Error> {
|
|
|
|
|
use crate::data::*;
|
|
|
|
|
|
|
|
|
|
tokio::try_join! {
|
|
|
|
|
Settings::save(),
|
|
|
|
|
Profiles::save(),
|
|
|
|
|
}?;
|
2021-12-15 22:24:08 -07:00
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
|
}
|