use crate::modrinth; use colored::*; use inquire::Select; use serde::Serialize; use std::fmt::{Display, Formatter}; #[derive(Serialize)] pub struct Pack { info: Info, } #[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, Forge, Neoforge, } impl Modloader { const VARIANTS: &'static [Modloader] = &[Self::Fabric, Self::Quilt, Self::Forge, Self::Neoforge]; } impl Display for Modloader { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { write!(f, "{self:?}") } } impl Pack { pub async fn init() { println!("Fetching Minecraft information"); let versions = modrinth::get_minecraft_versions().await.unwrap(); let versions = versions .iter() .filter(|x| x.version_type == "release".to_string()) .map(|x| x.version.clone()) .collect(); let modloader = Select::new("Modloader?", Modloader::VARIANTS.to_vec()) .prompt() .unwrap(); let version = Select::new("Minecraft version?", versions) .prompt() .unwrap(); } }