From 98f56de8b11b563f8323627322fddfb9b39c88c5 Mon Sep 17 00:00:00 2001 From: bigfoot547 Date: Wed, 5 Feb 2025 12:07:32 -0600 Subject: small cli changes --- ozone-cli/src/cli.rs | 28 +++++++++++++++++++++++----- ozone-cli/src/main.rs | 37 ++++++++++++++++++++++--------------- 2 files changed, 45 insertions(+), 20 deletions(-) (limited to 'ozone-cli') diff --git a/ozone-cli/src/cli.rs b/ozone-cli/src/cli.rs index d288e3c..407ee50 100644 --- a/ozone-cli/src/cli.rs +++ b/ozone-cli/src/cli.rs @@ -1,10 +1,28 @@ use std::path::PathBuf; use clap::{Args, Parser, Subcommand}; +#[derive(Args, Debug)] +pub struct ProfileSelectArgs { + /// The name of the profile to select. + #[arg(index = 1)] + pub profile: String +} + +#[derive(Args, Debug)] +pub struct ProfileCreateArgs { + /// The name of the new profile. + #[arg(index = 1)] + pub name: String, + + /// Clone profile information from an existing profile. + #[arg(long, short = 'c')] + pub clone: String +} + #[derive(Subcommand, Debug)] pub enum ProfileCommand { - Select, - Create, + Select(ProfileSelectArgs), + Create(ProfileCreateArgs), List } @@ -15,8 +33,8 @@ pub struct ProfileArgs { } impl ProfileArgs { - pub fn take_command(&mut self) -> ProfileCommand { - self.subcmd.take().unwrap_or(ProfileCommand::List) + pub fn command(&self) -> &ProfileCommand { + self.subcmd.as_ref().unwrap_or(&ProfileCommand::List) } } @@ -24,7 +42,7 @@ impl ProfileArgs { pub enum RootCommand { Profile(ProfileArgs), Instance, - + Launch } #[derive(Parser, Debug)] diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs index d0d7b21..346532a 100644 --- a/ozone-cli/src/main.rs +++ b/ozone-cli/src/main.rs @@ -16,15 +16,32 @@ async fn main_inner(cli: Cli) -> Result> { 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() { + match &cli.subcmd { + RootCommand::Profile(p) => match p.command() { ProfileCommand::List => { - todo!() + for (name, profile) in settings.get_profiles().iter() { + println!("{name}: {profile:#?}"); + } } _ => todo!() }, + RootCommand::Launch => { + settings.save().await?; + + let launcher = Launcher::new(&home, !cli.offline).await?; + let profile = settings.get_profiles().get("default").unwrap(); + + let launch = launcher.prepare_launch(profile, settings.get_instances().get(profile.get_instance_name()).unwrap(), settings.get_client_id()).await.map_err(|e| { + error!("error launching: {e}"); + e + })?; + + dbg!(&launch); + info!("ok"); + + ozone::launcher::run_the_game(&launch)?; + } _ => todo!() } @@ -46,15 +63,5 @@ async fn main() -> ExitCode { /*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)?;*/ + */ } -- cgit v1.2.3-70-g09d2