diff options
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 60 |
1 files changed, 60 insertions, 0 deletions
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 @@ | |||
| 1 | mod constants; | ||
| 2 | mod errors; | ||
| 3 | |||
| 4 | mod config; | ||
| 5 | mod minecraft; | ||
| 6 | mod platform; | ||
| 7 | mod util; | ||
| 8 | |||
| 9 | use clap::Parser; | ||
| 10 | use config::Config; | ||
| 11 | use errors::McError; | ||
| 12 | use log::{debug, info}; | ||
| 13 | |||
| 14 | #[derive(Parser, Debug)] | ||
| 15 | #[command(author, about, disable_version_flag = true)] | ||
| 16 | struct Cli { | ||
| 17 | #[arg(long)] | ||
| 18 | version: Option<String>, | ||
| 19 | |||
| 20 | #[arg(long)] | ||
| 21 | username: Option<String>, | ||
| 22 | |||
| 23 | #[arg(long, num_args(0..), allow_hyphen_values = true)] | ||
| 24 | jvm_args: Vec<String>, | ||
| 25 | } | ||
| 26 | |||
| 27 | #[tokio::main] | ||
| 28 | async fn main() -> Result<(), McError> { | ||
| 29 | dotenvy::dotenv().ok(); | ||
| 30 | env_logger::init(); | ||
| 31 | |||
| 32 | let cli = Cli::parse(); | ||
| 33 | let mut config = Config::load()?; | ||
| 34 | |||
| 35 | if let Some(v) = cli.version { | ||
| 36 | config.version = v; | ||
| 37 | } | ||
| 38 | |||
| 39 | if let Some(u) = cli.username { | ||
| 40 | config.username = u; | ||
| 41 | } | ||
| 42 | if !cli.jvm_args.is_empty() { | ||
| 43 | config.jvm_args = cli.jvm_args; | ||
| 44 | } | ||
| 45 | |||
| 46 | info!("Final config after CLI overrides: {:?}", config); | ||
| 47 | |||
| 48 | platform::paths::ensure_dirs(&config)?; | ||
| 49 | info!("Using Minecraft version {}", config.version); | ||
| 50 | |||
| 51 | let version = minecraft::manifests::load_version(&config).await?; | ||
| 52 | info!("Loaded version manifest for: {}", version.id); | ||
| 53 | debug!("Main class: {}", version.main_class); | ||
| 54 | |||
| 55 | minecraft::downloads::download_all(&config, &version).await?; | ||
| 56 | minecraft::extraction::extract_natives(&config, &version)?; | ||
| 57 | minecraft::launcher::launch(&config, &version)?; | ||
| 58 | |||
| 59 | Ok(()) | ||
| 60 | } | ||
