Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added version arg to CLI (#1)
* Added version arg to CL

Added `--version` to the CL so that it shows the verifiers' current versison. Path specificity is needed due to it picking up the main pom file in the root instead of inside liquidjava-verifier.

* Updated version text

Co-authored-by: Ricardo Costa <rcosta.ms358@gmail.com>

---------

Co-authored-by: Ricardo Costa <rcosta.ms358@gmail.com>
  • Loading branch information
cheestree and rcosta358 authored Apr 7, 2026
commit 62c0c67bff93d5f39591fabdc96f89e6f34f61af
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package liquidjava.api;

import java.io.FileReader;
import java.nio.file.Path;
import java.util.List;
import java.util.concurrent.Callable;

import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;

import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
Expand All @@ -12,9 +16,22 @@ public class CommandLineArgs {
@Option(names = {"-h", "--help"}, usageHelp = true, description = "Display this help message")
public boolean help;

@Option(names = { "-v", "--version" }, versionHelp = true, description = "Display the version of LiquidJava")
public boolean version;

@Option(names = { "-d", "--debug" }, description = "Enable debug mode for more detailed output")
public boolean debugMode;

@Parameters(arity = "1..*", paramLabel = "<...paths>", description = "Paths to be verified by LiquidJava")
public List<String> paths;

public String getVersionString() {
Path pomPath = Path.of("liquidjava-verifier", "pom.xml");
try (FileReader fileReader = new FileReader(pomPath.toFile())) {
Model model = new MavenXpp3Reader().read(fileReader);
return model.getVersion();
} catch (Exception ignored) {
return "unknown";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public static void main(String[] args) {
return;
}

if (cmd.isVersionHelpRequested()) {
System.out.println("liquidjava " + cmdArgs.getVersionString());
return;
}

launch(cmdArgs.paths.stream().toArray(String[]::new));

// print diagnostics
Expand Down
Loading