From 003277340d1500ca07f3e3e80f5e8357b3d72006 Mon Sep 17 00:00:00 2001 From: Hector Ventura Date: Fri, 15 May 2026 23:07:30 -0500 Subject: [PATCH] fix: showing wrong version on floci version command --- pom.xml | 6 ++++++ .../io/floci/cli/commands/VersionCommand.java | 15 ++++++++++++++- .../resources/io/floci/cli/version.properties | 1 + 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/io/floci/cli/version.properties diff --git a/pom.xml b/pom.xml index 972258e..2a89956 100644 --- a/pom.xml +++ b/pom.xml @@ -65,6 +65,12 @@ + + + src/main/resources + true + + org.apache.maven.plugins diff --git a/src/main/java/io/floci/cli/commands/VersionCommand.java b/src/main/java/io/floci/cli/commands/VersionCommand.java index 767c506..bcfc9d6 100644 --- a/src/main/java/io/floci/cli/commands/VersionCommand.java +++ b/src/main/java/io/floci/cli/commands/VersionCommand.java @@ -7,9 +7,11 @@ import io.floci.cli.output.OutputFormat; import io.floci.cli.output.Printer; import picocli.CommandLine.*; +import java.io.InputStream; import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; +import java.util.Properties; import java.util.concurrent.Callable; @Command( @@ -19,7 +21,18 @@ import java.util.concurrent.Callable; ) public class VersionCommand implements Callable { - public static final String CLI_VERSION = "0.1.0"; + public static final String CLI_VERSION = loadVersion(); + + private static String loadVersion() { + try (InputStream is = VersionCommand.class.getResourceAsStream("/io/floci/cli/version.properties")) { + if (is == null) return "unknown"; + Properties props = new Properties(); + props.load(is); + return props.getProperty("version", "unknown"); + } catch (Exception e) { + return "unknown"; + } + } @Mixin GlobalOptions global; diff --git a/src/main/resources/io/floci/cli/version.properties b/src/main/resources/io/floci/cli/version.properties new file mode 100644 index 0000000..defbd48 --- /dev/null +++ b/src/main/resources/io/floci/cli/version.properties @@ -0,0 +1 @@ +version=${project.version}