summaryrefslogtreecommitdiffstats
path: root/ozone-cli
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-02-10 02:35:07 -0600
committerLibravatar bigfoot547 <[email protected]>2025-02-10 02:35:07 -0600
commit912916abebd1f921261244ee8a4a7dfa40c11a9c (patch)
tree259828ff30a548ce42ca007c8d6a60daa975653a /ozone-cli
parentfinish up changes (diff)
last commit before rewriting settings system??
Diffstat (limited to 'ozone-cli')
-rw-r--r--ozone-cli/src/main.rs46
1 files changed, 35 insertions, 11 deletions
diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs
index adfeb71..e0cbada 100644
--- a/ozone-cli/src/main.rs
+++ b/ozone-cli/src/main.rs
@@ -2,10 +2,10 @@ mod cli;
use std::error::Error;
use std::process::ExitCode;
-use log::{error, info, trace};
+use log::{error, info, trace, LevelFilter};
use clap::Parser;
-use ozone::launcher::{Launcher, Settings};
-use ozone::launcher::version::VersionList;
+use ozone::launcher::{Instance, Launcher, Profile, Settings};
+use ozone::launcher::version::{VersionList, VersionResult};
use crate::cli::{Cli, ProfileCommand, RootCommand};
async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> {
@@ -38,7 +38,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> {
let exists = if settings.get_instances().contains_key(profile.get_instance_name()) { "" } else { " (missing!)" };
println!("Profile {name}:{sel}");
- println!(" Version: {}", profile.get_version());
+ println!(" Version: {}", profile.game_version);
println!(" Instance: {}{}", profile.get_instance_name(), exists);
}
},
@@ -48,23 +48,46 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> {
return Ok(ExitCode::FAILURE);
}
- if let Some(ref src) = args.clone {
+ if let Err(e) = Profile::check_name(&args.name) {
+ eprintln!("The profile name is invalid: {e}");
+ return Ok(ExitCode::FAILURE);
+ }
+
+ let mut profile = if let Some(ref src) = args.clone {
if let Some(profile) = settings.get_profiles().get(src) {
- let profile = profile.clone();
- settings.profiles.insert(args.name.clone(), profile);
+ profile.clone()
} else {
eprintln!("Unknown profile `{src}'.");
return Ok(ExitCode::FAILURE);
}
+ } else {
+ let inst_name = args.instance.as_ref().unwrap_or(&args.name);
+ if let Err(e) = Instance::check_name(inst_name) {
+ eprintln!("The profile name is invalid for an instance: {e}");
+ eprintln!("Please specify an instance name manually with --instance.");
+ return Ok(ExitCode::FAILURE);
+ }
- return Ok(ExitCode::SUCCESS);
- }
+ Profile::new(inst_name)
+ };
// creating a new profile from scratch
todo!()
},
ProfileCommand::Select(args) => {
-
+ let ver = VersionList::new(home.join("versions"), !cli.offline).await?;
+
+ match ver.get_version_lazy(&args.profile) {
+ VersionResult::None => {
+ println!("Unknown version");
+ },
+ VersionResult::Remote(v) => {
+ println!("Remote version: {v:?}");
+ },
+ VersionResult::Complete(v) => {
+ println!("Complete version: {v:?}");
+ }
+ }
}
_ => todo!()
},
@@ -92,7 +115,8 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> {
#[tokio::main]
async fn main() -> ExitCode {
- simple_logger::SimpleLogger::new().env().init().unwrap();
+ // use Warn as the default level to minimize noise on the command line
+ simple_logger::SimpleLogger::new().with_level(LevelFilter::Warn).env().init().unwrap();
let arg = Cli::parse();