summaryrefslogtreecommitdiffstats
path: root/ozone-cli
diff options
context:
space:
mode:
Diffstat (limited to 'ozone-cli')
-rw-r--r--ozone-cli/Cargo.toml3
-rw-r--r--ozone-cli/src/cli.rs46
-rw-r--r--ozone-cli/src/main.rs47
-rw-r--r--ozone-cli/work/ozone.json24
4 files changed, 110 insertions, 10 deletions
diff --git a/ozone-cli/Cargo.toml b/ozone-cli/Cargo.toml
index e793eaa..dbbda5d 100644
--- a/ozone-cli/Cargo.toml
+++ b/ozone-cli/Cargo.toml
@@ -4,9 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-sysinfo = { version = "0.33.1", features = ["system", "multithread"] }
ozone = { path = "../ozone" }
tokio = { version = "1.43.0", features = ["rt", "rt-multi-thread", "macros"] }
simple_logger = { version = "5.0.0", features = ["colors"] }
log = "0.4.25"
-clap = "4.5.27"
+clap = { version = "4.5.27", features = ["derive", "cargo"] }
diff --git a/ozone-cli/src/cli.rs b/ozone-cli/src/cli.rs
new file mode 100644
index 0000000..d288e3c
--- /dev/null
+++ b/ozone-cli/src/cli.rs
@@ -0,0 +1,46 @@
+use std::path::PathBuf;
+use clap::{Args, Parser, Subcommand};
+
+#[derive(Subcommand, Debug)]
+pub enum ProfileCommand {
+ Select,
+ Create,
+ List
+}
+
+#[derive(Args, Debug)]
+pub struct ProfileArgs {
+ #[command(subcommand)]
+ subcmd: Option<ProfileCommand>
+}
+
+impl ProfileArgs {
+ pub fn take_command(&mut self) -> ProfileCommand {
+ self.subcmd.take().unwrap_or(ProfileCommand::List)
+ }
+}
+
+#[derive(Subcommand, Debug)]
+pub enum RootCommand {
+ Profile(ProfileArgs),
+ Instance,
+
+}
+
+#[derive(Parser, Debug)]
+#[clap(version)]
+pub struct Cli {
+ /// Run the launcher in offline mode. The launcher will not attempt to make any requests using
+ /// the network. The launcher _will_ verify the integrity of files required to launch the game,
+ /// and refuse to launch the game with an error if it must download a file.
+ #[arg(long, global = true)]
+ pub offline: bool,
+
+ /// Directory which the launcher will perform its work in. Defaults to an application-specific
+ /// directory based on your OS.
+ #[arg(long, global = true, value_hint = clap::ValueHint::DirPath)]
+ pub home: Option<PathBuf>,
+
+ #[command(subcommand)]
+ pub subcmd: RootCommand
+}
diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs
index a17979e..b449209 100644
--- a/ozone-cli/src/main.rs
+++ b/ozone-cli/src/main.rs
@@ -1,16 +1,49 @@
+mod cli;
+
use std::error::Error;
+use std::path::PathBuf;
+use std::process::{ExitCode, ExitStatus};
use log::{error, info};
+use clap::{Args, Parser, Subcommand};
use ozone::launcher::{Launcher, Settings};
+use crate::cli::{Cli, ProfileCommand, RootCommand};
+
+async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> {
+ let Some(home) = cli.home.or_else(|| Launcher::sensible_home()) else {
+ error!("Could not choose a launcher home directory. Please choose one with `--home'.");
+ Ok(ExitCode::FAILURE) // we print our own error message
+ };
+
+ info!("Sensible home could be {home:?}");
+ let settings = Settings::load(home.join("ozone.json")).await?;
+ settings.save().await?;
+
+ match cli.subcmd {
+ RootCommand::Profile(mut p) => match p.take_command() {
+ ProfileCommand::List => {
+
+ }
+ }
+ }
+
+ Ok(ExitCode::SUCCESS)
+}
+
#[tokio::main]
-async fn main() -> Result<(), Box<dyn Error>> {
+async fn main() -> ExitCode {
simple_logger::SimpleLogger::new().env().init().unwrap();
- info!("Sensible home could be {:?}", Launcher::sensible_home());
- let settings = Settings::load("./work/ozone.json").await?;
- settings.save().await?;
+ let arg = dbg!(Cli::parse());
- let launcher = Launcher::new("./work", true).await?;
+ main_inner(arg).await.unwrap_or_else(|e| {
+ error!("Launcher initialization error:");
+ error!("{e}");
+
+ ExitCode::FAILURE
+ })
+
+ /*let launcher = Launcher::new("./work", true).await?;
let profile = settings.get_profile("default").unwrap();
@@ -22,7 +55,5 @@ async fn main() -> Result<(), Box<dyn Error>> {
dbg!(&launch);
info!("ok");
- ozone::launcher::run_the_game(&launch)?;
-
- Ok(())
+ ozone::launcher::run_the_game(&launch)?;*/
}
diff --git a/ozone-cli/work/ozone.json b/ozone-cli/work/ozone.json
new file mode 100644
index 0000000..f1ed208
--- /dev/null
+++ b/ozone-cli/work/ozone.json
@@ -0,0 +1,24 @@
+{
+ "profiles": {
+ "default": {
+ "game_version": "latest_release",
+ "java_runtime": null,
+ "instance": "default",
+ "jvm_arguments": [
+ "-Xmx2G",
+ "-XX:+UnlockExperimentalVMOptions",
+ "-XX:+UseG1GC",
+ "-XX:G1NewSizePercent=20",
+ "-XX:G1ReservePercent=20",
+ "-XX:MaxGCPauseMillis=50",
+ "-XX:G1HeapRegionSize=32M"
+ ]
+ }
+ },
+ "instances": {
+ "default": {
+ "path": "default"
+ }
+ },
+ "client_id": "8e1cd116-9100-46cb-86b8-1a4ad54c5cbe"
+} \ No newline at end of file