From eb88139c45acc50a6313e1a7cd9c6efdd64ef1a9 Mon Sep 17 00:00:00 2001
From: Alex <42661490+ThatRedox@users.noreply.github.com>
Date: Sat, 19 Oct 2024 16:30:55 -0700
Subject: [PATCH] Improve the launcher command line interface and improve setup
command. (#1682)
* More in-depth `--setup`. Add defaults and way to update release channels.
* Bundle apache commons CLI. Port CLI parsing. Add simple test for parsing.
* Fix argument for `--javaOptions`
* Remove `stopAtNonOption`. Remove `--updateAlpha` and `--nolauncher`
* Add apache commons CLI to tools and libraries. Make help dialog better. Centralize copyright lines and CLI utilities.
* Remove release channel selection from interactive setup.
* Add update site to cli setup. Rename reload release channels to launcher metadata. Make update printout nicer.
* Add Apache Commons CLI to the readme.
---
README.md | 3 +
.../ui/controller/CreditsController.java | 15 +-
.../se/llbit/chunky/ui/dialogs/Credits.fxml | 16 +-
launcher/build.gradle | 27 +-
.../llbit/chunky/launcher/ChunkyLauncher.java | 380 +++++++++++++-----
.../launcher/ChunkyLauncherCliParseTest.java | 103 +++++
lib/src/se/llbit/chunky/HelpCopyright.java | 30 ++
lib/src/se/llbit/chunky/cli/CliUtil.java | 41 ++
8 files changed, 503 insertions(+), 112 deletions(-)
create mode 100644 launcher/test/se/llbit/chunky/launcher/ChunkyLauncherCliParseTest.java
create mode 100644 lib/src/se/llbit/chunky/HelpCopyright.java
create mode 100644 lib/src/se/llbit/chunky/cli/CliUtil.java
diff --git a/README.md b/README.md
index 20cd0b5a7..8f8d0fb16 100644
--- a/README.md
+++ b/README.md
@@ -203,6 +203,9 @@ Chunky uses the following 3rd party libraries:
- **Apache Maven Artifact by the Apache Software Foundation**
The library is covered by the Apache License, version 2.0.
See the file `licenses/Apache-2.0.txt` for the full license text.
+- **Apache Commons CLI by the Apache Software Foundation**
+ The library is covered by the Apache License, version 2.0.
+ See the file `licenses/Apache-2.0.txt` for the full license text.
- **FastUtil by Sebastiano Vigna**
FastUtil is covered by Apache License, version 2.0.
See the file `licenses/Apache-2.0.txt` for the full license text.
diff --git a/chunky/src/java/se/llbit/chunky/ui/controller/CreditsController.java b/chunky/src/java/se/llbit/chunky/ui/controller/CreditsController.java
index 6b38a46fd..d491ed296 100644
--- a/chunky/src/java/se/llbit/chunky/ui/controller/CreditsController.java
+++ b/chunky/src/java/se/llbit/chunky/ui/controller/CreditsController.java
@@ -40,6 +40,7 @@
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.stage.Stage;
+import se.llbit.chunky.HelpCopyright;
import se.llbit.chunky.main.Chunky;
import se.llbit.chunky.plugin.PluginApi;
import se.llbit.chunky.ui.ChunkyFx;
@@ -49,10 +50,11 @@
import se.llbit.util.Pair;
public class CreditsController implements Initializable {
-
@FXML
private Label version;
@FXML
+ public Label copyrightLine;
+ @FXML
private Hyperlink gplv3;
@FXML
private Hyperlink markdown;
@@ -83,6 +85,10 @@ public class CreditsController implements Initializable {
@FXML
private Hyperlink lz4JavaLicense;
@FXML
+ private Hyperlink apacheCli;
+ @FXML
+ private Hyperlink apacheCliLicense;
+ @FXML
private VBox pluginBox;
@FXML
private ImageView logoImage;
@@ -140,6 +146,8 @@ public void initialize(URL location, ResourceBundle resources) {
version.setText(Chunky.getMainWindowTitle());
+ copyrightLine.setText(HelpCopyright.COPYRIGHT_LINE);
+
gplv3.setOnAction(
e -> launchAndReset(gplv3, "https://github.com/chunky-dev/chunky/blob/master/LICENSE")
);
@@ -189,6 +197,11 @@ public void initialize(URL location, ResourceBundle resources) {
lz4JavaLicense.setBorder(Border.EMPTY);
lz4JavaLicense.setOnAction(e -> launchAndReset(lz4JavaLicense, "https://github.com/lz4/lz4-java/blob/master/LICENSE.txt"));
+ apacheCli.setBorder(Border.EMPTY);
+ apacheCli.setOnAction(e -> launchAndReset(apacheCli, "https://commons.apache.org/proper/commons-cli/"));
+ apacheCliLicense.setBorder(Border.EMPTY);
+ apacheCliLicense.setOnAction(e -> launchAndReset(apacheCliLicense, "http://www.apache.org/licenses/LICENSE-2.0"));
+
if (!plugins.isEmpty()) {
plugins.forEach((key, item) -> pluginBox.getChildren().addAll(buildBox(item)));
} else {
diff --git a/chunky/src/res/se/llbit/chunky/ui/dialogs/Credits.fxml b/chunky/src/res/se/llbit/chunky/ui/dialogs/Credits.fxml
index bbc38015e..e3227eba3 100644
--- a/chunky/src/res/se/llbit/chunky/ui/dialogs/Credits.fxml
+++ b/chunky/src/res/se/llbit/chunky/ui/dialogs/Credits.fxml
@@ -31,7 +31,7 @@
-