summaryrefslogtreecommitdiffstats
path: root/ozone-cli/src/main.rs
blob: b44920934d325075151e63698c290774471a5b8e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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() -> ExitCode {
    simple_logger::SimpleLogger::new().env().init().unwrap();

    let arg = dbg!(Cli::parse());

    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();

    let launch = launcher.prepare_launch(profile, settings.get_instance_for(profile)).await.map_err(|e| {
        error!("error launching: {e}");
        e
    })?;
    
    dbg!(&launch);
    info!("ok");

    ozone::launcher::run_the_game(&launch)?;*/
}