From 1e9980f7b9af6195895796d4b1516e4d38149f3e Mon Sep 17 00:00:00 2001 From: Raphael Vullriede Date: Mon, 9 Dec 2024 19:45:50 +0100 Subject: [PATCH] feat: add cmd param to get current version --- .../workflows/build-release-on-main-push.yml | 2 +- pom.xml | 12 +++--- .../net/osslabz/loggazer/LogGazerApp.java | 41 +++++++++++++------ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-release-on-main-push.yml b/.github/workflows/build-release-on-main-push.yml index 546faef..454b8c7 100644 --- a/.github/workflows/build-release-on-main-push.yml +++ b/.github/workflows/build-release-on-main-push.yml @@ -16,7 +16,7 @@ jobs: strategy: max-parallel: 1 # otherwise the release upload will fail matrix: - os: [ macos-14, macos-13, windows-latest, ubuntu] # ubuntu-latest, windows-latest, macos-13, + os: [ macos-14, macos-13, windows-latest, ubuntu-latest ] runs-on: ${{ matrix.os }} diff --git a/pom.xml b/pom.xml index d27479a..488c788 100644 --- a/pom.xml +++ b/pom.xml @@ -1,11 +1,11 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 net.osslabz log-gazer - 1.1.6 + 1.2.0 UTF-8 @@ -18,8 +18,6 @@ ${osslabz.java.version} net.osslabz.loggazer.LogGazerApp - - 1.6.5 @@ -183,6 +181,7 @@ + org.apache.maven.plugins maven-assembly-plugin 3.7.1 @@ -217,6 +216,7 @@ + org.apache.maven.plugins maven-assembly-plugin 3.7.1 @@ -251,6 +251,7 @@ + org.apache.maven.plugins maven-assembly-plugin 3.7.1 @@ -312,7 +313,7 @@ + implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> ${mainClass} @@ -328,6 +329,7 @@ ${mainClass} + true diff --git a/src/main/java/net/osslabz/loggazer/LogGazerApp.java b/src/main/java/net/osslabz/loggazer/LogGazerApp.java index 314e2d7..cca5446 100644 --- a/src/main/java/net/osslabz/loggazer/LogGazerApp.java +++ b/src/main/java/net/osslabz/loggazer/LogGazerApp.java @@ -11,7 +11,6 @@ import java.util.UUID; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - import javafx.application.Application; import javafx.concurrent.Task; import javafx.scene.Scene; @@ -77,6 +76,24 @@ public class LogGazerApp extends Application { public static void main(String[] args) { + if (args != null && args.length == 1) { + String singleParam = args[0]; + if (singleParam != null) { + String paramLowerCase = StringUtils.stripStart(singleParam.trim().toLowerCase(), "-"); + if (paramLowerCase.equals("version") || paramLowerCase.equals("v")) { + System.out.printf( + """ + log-gazer %s%n + Copyright (C) 2024 Raphael Vullriede (raphael@osslabz.net)%n + License: Apache License Version 2.0, January 2004 .%n + This is free software: you are free to change and redistribute it.%n + There is NO WARRANTY, to the extent permitted by law.%n + """, LogGazerApp.class.getPackage().getImplementationVersion()); + System.exit(0); + } + } + } + launch(args); } @@ -175,15 +192,15 @@ private ToolBar createToolBar() { resetSearch(); toolBar.getItems().addAll( - this.buttonFormatJson, - new Separator(), - this.buttonMarkLogLevel, - new Separator(), - this.searchField, - this.searchButton, - this.prevMatchButton, - this.nextMatchButton, - this.matchCountLabel + this.buttonFormatJson, + new Separator(), + this.buttonMarkLogLevel, + new Separator(), + this.searchField, + this.searchButton, + this.prevMatchButton, + this.nextMatchButton, + this.matchCountLabel ); @@ -237,7 +254,7 @@ private void navigateToCurrentMatch() { int numMatches = tabContent.getSearchData().numMatches(); searchField.setText(StringUtils.isNotBlank(tabContent.getSearchData().getQuery()) ? tabContent.getSearchData().getQuery() : - SEARCH_QUERY_PLACEHOLDER); + SEARCH_QUERY_PLACEHOLDER); matchCountLabel.setText(String.format("%d of %d matches", currentMatchIndex + 1, numMatches)); if (currentMatchIndex >= 0 && currentMatchIndex < numMatches) { @@ -470,7 +487,7 @@ private void openFile() { new FileChooser.ExtensionFilter("Compressed Files", "*.gz", "*.zip", "*.tar.gz") */ - new FileChooser.ExtensionFilter("Files", "*.*") + new FileChooser.ExtensionFilter("Files", "*.*") ); File file = fileChooser.showOpenDialog(null);