From 72ddd7b7704f2087a52c9c0552446682918c513b Mon Sep 17 00:00:00 2001 From: Filip Wandzio Date: Thu, 22 Jan 2026 23:14:08 +0100 Subject: Implement basic game files download logic Implement core clap arguments Respect XDG_BASE_DIR Currently library extraction is broken because it assumes every instace has it's own library folder. This should be refactored so instances share libraries Signed-off-by: Filip Wandzio --- src/main.rs | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..8a01b9f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,60 @@ +mod constants; +mod errors; + +mod config; +mod minecraft; +mod platform; +mod util; + +use clap::Parser; +use config::Config; +use errors::McError; +use log::{debug, info}; + +#[derive(Parser, Debug)] +#[command(author, about, disable_version_flag = true)] +struct Cli { + #[arg(long)] + version: Option, + + #[arg(long)] + username: Option, + + #[arg(long, num_args(0..), allow_hyphen_values = true)] + jvm_args: Vec, +} + +#[tokio::main] +async fn main() -> Result<(), McError> { + dotenvy::dotenv().ok(); + env_logger::init(); + + let cli = Cli::parse(); + let mut config = Config::load()?; + + if let Some(v) = cli.version { + config.version = v; + } + + if let Some(u) = cli.username { + config.username = u; + } + if !cli.jvm_args.is_empty() { + config.jvm_args = cli.jvm_args; + } + + info!("Final config after CLI overrides: {:?}", config); + + platform::paths::ensure_dirs(&config)?; + info!("Using Minecraft version {}", config.version); + + let version = minecraft::manifests::load_version(&config).await?; + info!("Loaded version manifest for: {}", version.id); + debug!("Main class: {}", version.main_class); + + minecraft::downloads::download_all(&config, &version).await?; + minecraft::extraction::extract_natives(&config, &version)?; + minecraft::launcher::launch(&config, &version)?; + + Ok(()) +} -- cgit v1.2.3