Compare commits
No commits in common. "712b95e24d824092873bda130b158e01f25ad1a1" and "2f057425c3f79d4607a2d59fdf7ffa13421f3387" have entirely different histories.
712b95e24d
...
2f057425c3
3 changed files with 3 additions and 47 deletions
32
src/main.rs
32
src/main.rs
|
|
@ -1,7 +1,6 @@
|
|||
mod models;
|
||||
mod utils;
|
||||
|
||||
use crate::models::config::{Config, Mods, Server};
|
||||
use crate::models::fabric::FabricVersions;
|
||||
use crate::{
|
||||
models::vanilla::{VanillaVersionDetail, VanillaVersionType, VanillaVersions},
|
||||
|
|
@ -33,7 +32,7 @@ struct Mcsm {
|
|||
|
||||
#[derive(Subcommand)]
|
||||
enum Commands {
|
||||
Create { project_name: String },
|
||||
Init { name: String },
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
|
|
@ -41,10 +40,9 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
let mcsm = Mcsm::parse();
|
||||
|
||||
match mcsm.command {
|
||||
Commands::Create { project_name } => {
|
||||
tokio::fs::create_dir_all(&project_name).await?;
|
||||
Commands::Init { name: project_name } => {
|
||||
tokio::fs::create_dir(&project_name).await?;
|
||||
std::env::set_current_dir(&project_name)?;
|
||||
let mut config_file = tokio::fs::File::create("mcsm.toml").await?;
|
||||
|
||||
let loaders = vec!["Vanilla", "Fabric"];
|
||||
let loader_index = Select::with_theme(&ColorfulTheme::default())
|
||||
|
|
@ -127,18 +125,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
|
||||
let config = Config {
|
||||
server: Server {
|
||||
version: release_version_names[version_index].to_string(),
|
||||
loader: loaders[loader_index].to_string(),
|
||||
loader_version: None,
|
||||
},
|
||||
mods: Mods {},
|
||||
};
|
||||
config_file
|
||||
.write_all(toml::to_string(&config)?.as_bytes())
|
||||
.await?;
|
||||
}
|
||||
1 => {
|
||||
const URL: &str = "https://meta.fabricmc.net/v2/versions";
|
||||
|
|
@ -210,18 +196,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
|
||||
let config = Config {
|
||||
server: Server {
|
||||
version: game_version,
|
||||
loader: loaders[loader_index].to_string(),
|
||||
loader_version: Some(loader_version),
|
||||
},
|
||||
mods: Mods {},
|
||||
};
|
||||
config_file
|
||||
.write_all(toml::to_string(&config)?.as_bytes())
|
||||
.await?;
|
||||
}
|
||||
_ => return Err("Invalid selection".into()),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Config {
|
||||
pub server: Server,
|
||||
pub mods: Mods,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Server {
|
||||
pub version: String,
|
||||
pub loader: String,
|
||||
pub loader_version: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
pub struct Mods {}
|
||||
|
|
@ -1,3 +1,2 @@
|
|||
pub mod config;
|
||||
pub mod fabric;
|
||||
pub mod vanilla;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue