diff options
| author | 2025-02-11 15:49:51 -0600 | |
|---|---|---|
| committer | 2025-02-11 15:49:51 -0600 | |
| commit | 8ce32074bee601ebdd266b8f9c8f1eaa9a834222 (patch) | |
| tree | e1e7f592a14f2ba93d27827c5bc93ec2373ac12d /ozone-cli | |
| parent | more profile management stuff (diff) | |
add some documentation
Diffstat (limited to 'ozone-cli')
| -rw-r--r-- | ozone-cli/src/cli.rs | 31 | ||||
| -rw-r--r-- | ozone-cli/src/main.rs | 20 |
2 files changed, 45 insertions, 6 deletions
diff --git a/ozone-cli/src/cli.rs b/ozone-cli/src/cli.rs index ad5769b..d145e89 100644 --- a/ozone-cli/src/cli.rs +++ b/ozone-cli/src/cli.rs @@ -71,9 +71,9 @@ pub struct InstanceSettingsArgs { /// Specify the resolution of the Minecraft game window. Note that this argument is a suggestion
/// to the game process, and could be ignored or unsupported on some versions.
///
- /// Pass the resolution as _width_x_height_ (like `800x600').
+ /// Pass the resolution as WIDTHxHEIGHT (like `800x600').
///
- /// Use the special value _default_ to reset to the default value.
+ /// Use the special value `default' to reset to the default value.
#[arg(long, short = 'r', value_parser = parse_resolution_argument)]
pub resolution: Option<Option<Resolution>>,
}
@@ -122,11 +122,29 @@ pub struct InstanceCreateArgs { #[derive(Subcommand, Debug)]
pub enum InstanceCommand {
+ /// Selects an instance.
Select(InstanceSelectArgs),
+
+ /// Creates an instance, optionally cloning the selected instance.
Create(InstanceCreateArgs),
+
+ /// Change the configuration of an instance.
Set(InstanceSettingsArgs),
+
+ /// Rename an instance.
+ Rename {
+ /// The new name for the instance
+ #[arg(index = 1)]
+ name: String
+ },
+
+ /// Deletes the selected instance.
Delete,
+
+ /// Lists known instances.
List,
+
+ /// Shows complete information about the selected instance.
Info
}
@@ -144,7 +162,14 @@ impl InstanceArgs { #[derive(Subcommand, Debug)]
pub enum RootCommand {
+ /// Manages instances.
+ ///
+ /// An instance in terms of this launcher is a set of settings which decides how to launch the
+ /// game. This includes a version of the game, a set of JVM arguments, and other miscellaneous
+ /// settings. Each instance runs the game in a separate directory.
Instance(InstanceArgs),
+
+ /// Launches the selected instance with the selected account.
Launch
}
@@ -152,7 +177,7 @@ pub enum RootCommand { #[clap(version)]
pub struct Cli {
/// Run the launcher in offline mode. The launcher will not attempt to make any requests using
- /// the network. The launcher _will_ verify the integrity of files required to launch the game,
+ /// the network. The launcher WILL verify the integrity of files required to launch the game,
/// and refuse to launch the game with an error if it must download a file.
#[arg(long, global = true)]
pub offline: bool,
diff --git a/ozone-cli/src/main.rs b/ozone-cli/src/main.rs index d857cd1..5174348 100644 --- a/ozone-cli/src/main.rs +++ b/ozone-cli/src/main.rs @@ -51,7 +51,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { } let mut inst = if args.clone { - if let Some(selected_inst) = settings.selected_instance.and_then(|i| settings.instances.get(&i)) { + if let Some(selected_inst) = settings.get_selected_instance() { let mut inst = selected_inst.clone(); inst.name.replace_range(.., &args.name); inst @@ -125,7 +125,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { settings.save().await?; }, InstanceCommand::Set(args) => { - let Some(inst) = settings.selected_instance.and_then(|i| settings.instances.get_mut(&i)) else { + let Some(inst) = settings.get_selected_instance_mut() else { eprintln!("No instance selected."); return Ok(ExitCode::FAILURE); }; @@ -144,7 +144,7 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { settings.save().await?; }, InstanceCommand::Info => { - let Some(inst) = settings.selected_instance.and_then(|i| settings.instances.get(&i)) else { + let Some(inst) = settings.get_selected_instance() else { eprintln!("No instance selected."); return Ok(ExitCode::FAILURE); }; @@ -161,6 +161,20 @@ async fn main_inner(cli: Cli) -> Result<ExitCode, Box<dyn Error>> { if let Some(res) = inst.resolution { println!(" Game resolution: {}x{}", res.width, res.height); } + }, + InstanceCommand::Rename { name } => { + if name.is_empty() { + eprintln!("The instance must not have an empty name."); + return Ok(ExitCode::FAILURE); + } + + let Some(inst) = settings.get_selected_instance_mut() else { + eprintln!("No instance selected."); + return Ok(ExitCode::FAILURE); + }; + + inst.name.replace_range(.., &name); + settings.save().await?; } }, RootCommand::Launch => { |
