Added ability to initialze a modpack

This commit is contained in:
xeovalyte 2024-05-28 14:44:46 +02:00
parent 5ad70e0a27
commit 20dddba0d5
No known key found for this signature in database
2 changed files with 13 additions and 3 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
/target /target
.packium.toml

View File

@ -12,12 +12,10 @@ pub struct Pack {
#[derive(Serialize)] #[derive(Serialize)]
pub struct Info { pub struct Info {
loader: Modloader, loader: Modloader,
loader_version: String,
minecraft_version: String, minecraft_version: String,
} }
#[derive(Serialize, Debug, Clone, Copy)] #[derive(Serialize, Debug, Clone, Copy)]
#[serde(untagged)]
pub enum Modloader { pub enum Modloader {
Fabric, Fabric,
Quilt, Quilt,
@ -38,7 +36,7 @@ impl Display for Modloader {
impl Pack { impl Pack {
pub async fn init() { pub async fn init() {
println!("Fetching Minecraft information"); println!("Fetching Minecraft information...");
let versions = modrinth::get_minecraft_versions().await.unwrap(); let versions = modrinth::get_minecraft_versions().await.unwrap();
@ -55,5 +53,16 @@ impl Pack {
let version = Select::new("Minecraft version?", versions) let version = Select::new("Minecraft version?", versions)
.prompt() .prompt()
.unwrap(); .unwrap();
let pack = Pack {
info: Info {
minecraft_version: version,
loader: modloader,
},
};
let pack_toml = toml::to_string_pretty(&pack).unwrap();
std::fs::write(".packium.toml", pack_toml).unwrap();
} }
} }