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
.packium.toml

View File

@ -12,12 +12,10 @@ pub struct Pack {
#[derive(Serialize)]
pub struct Info {
loader: Modloader,
loader_version: String,
minecraft_version: String,
}
#[derive(Serialize, Debug, Clone, Copy)]
#[serde(untagged)]
pub enum Modloader {
Fabric,
Quilt,
@ -38,7 +36,7 @@ impl Display for Modloader {
impl Pack {
pub async fn init() {
println!("Fetching Minecraft information");
println!("Fetching Minecraft information...");
let versions = modrinth::get_minecraft_versions().await.unwrap();
@ -55,5 +53,16 @@ impl Pack {
let version = Select::new("Minecraft version?", versions)
.prompt()
.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();
}
}