Added some first steps
This commit is contained in:
commit
5ad70e0a27
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
1610
Cargo.lock
generated
Normal file
1610
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "packium"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.4", features = [ "derive" ]}
|
||||
toml = "0.8.13"
|
||||
inquire = "0.7.5"
|
||||
serde = { version = "1.0.203", features = [ "derive" ]}
|
||||
colored = "2.1.0"
|
||||
reqwest = { version = "0.12.4", features = [ "json" ]}
|
||||
tokio = { version = "1.37.0", features = [ "full" ] }
|
130
flake.lock
Normal file
130
flake.lock
Normal file
@ -0,0 +1,130 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils_2": {
|
||||
"inputs": {
|
||||
"systems": "systems_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1705309234,
|
||||
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1716509168,
|
||||
"narHash": "sha256-4zSIhSRRIoEBwjbPm3YiGtbd8HDWzFxJjw5DYSDy1n8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "bfb7a882678e518398ce9a31a881538679f6f092",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1706487304,
|
||||
"narHash": "sha256-LE8lVX28MV2jWJsidW13D2qrHU/RUUONendL2Q/WlJg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "90f456026d284c22b3e3497be980b2e47d0b28ac",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1716862669,
|
||||
"narHash": "sha256-7oTPM9lcdwiI1cpRC313B+lHawocgpY5F07N+Rbm5Uk=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "47b2d15658b37716393b2463a019000dbd6ce4bc",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems_2": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
33
flake.nix
Normal file
33
flake.nix
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
description = "Rust development shell";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
in
|
||||
{
|
||||
devShells.default = with pkgs; mkShell {
|
||||
buildInputs = [
|
||||
openssl
|
||||
pkg-config
|
||||
(rust-bin.stable.latest.default.override {
|
||||
extensions = [ "rust-src" "rust-analyzer" ];
|
||||
})
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
27
src/cli.rs
Normal file
27
src/cli.rs
Normal file
@ -0,0 +1,27 @@
|
||||
use clap::{Parser, Subcommand};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(author, version, about, long_about = None)]
|
||||
#[command(propagate_version = true)]
|
||||
pub struct Cli {
|
||||
#[command(subcommand)]
|
||||
pub command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug)]
|
||||
pub enum Commands {
|
||||
/// Initialize a new modpack
|
||||
Init,
|
||||
|
||||
/// List the mods in the modpack
|
||||
List,
|
||||
|
||||
/// List the information of the modpack
|
||||
Info,
|
||||
|
||||
/// Add a mod to the modpack
|
||||
Add {
|
||||
/// The name of the mod to add
|
||||
name: String,
|
||||
},
|
||||
}
|
17
src/main.rs
Normal file
17
src/main.rs
Normal file
@ -0,0 +1,17 @@
|
||||
mod cli;
|
||||
mod modrinth;
|
||||
mod pack;
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let args = cli::Cli::parse();
|
||||
|
||||
match &args.command {
|
||||
cli::Commands::Init => {
|
||||
pack::Pack::init().await;
|
||||
}
|
||||
_ => (),
|
||||
};
|
||||
}
|
16
src/modrinth.rs
Normal file
16
src/modrinth.rs
Normal file
@ -0,0 +1,16 @@
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct MinecraftVersion {
|
||||
pub version: String,
|
||||
pub version_type: String,
|
||||
pub date: String,
|
||||
pub major: bool,
|
||||
}
|
||||
|
||||
pub async fn get_minecraft_versions() -> Result<Vec<MinecraftVersion>, reqwest::Error> {
|
||||
reqwest::get("https://api.modrinth.com/v2/tag/game_version")
|
||||
.await?
|
||||
.json::<Vec<MinecraftVersion>>()
|
||||
.await
|
||||
}
|
59
src/pack.rs
Normal file
59
src/pack.rs
Normal file
@ -0,0 +1,59 @@
|
||||
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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user