diff options
| author | 2025-02-05 12:07:32 -0600 | |
|---|---|---|
| committer | 2025-02-05 12:07:32 -0600 | |
| commit | 98f56de8b11b563f8323627322fddfb9b39c88c5 (patch) | |
| tree | a8e191490ce52bbf85d26703e026442e41b22281 /ozone-cli | |
| parent | no changes ignore (diff) | |
small cli changes
Diffstat (limited to 'ozone-cli')
| -rw-r--r-- | ozone-cli/src/cli.rs | 28 | ||||
| -rw-r--r-- | ozone-cli/src/main.rs | 37 |
2 files changed, 45 insertions, 20 deletions
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<ExitCode, Box<dyn Error>> { 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)?;*/ + */ } |
