summaryrefslogtreecommitdiffstats
path: root/ozone-cli/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'ozone-cli/src/main.rs')
-rw-r--r--ozone-cli/src/main.rs47
1 files changed, 39 insertions, 8 deletions
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)?;*/
}