From 39971536f3a5e19d6aa47ce640dbeb954eae02db Mon Sep 17 00:00:00 2001 From: MikhailLipanin Date: Tue, 29 Nov 2022 00:47:41 +0300 Subject: [PATCH] automatic project version and EO version --- pom.xml | 6 +++++ src/main/java/org/eolang/dejump/Main.java | 27 ++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index a58f749..c7a1d87 100644 --- a/pom.xml +++ b/pom.xml @@ -131,6 +131,11 @@ SOFTWARE. picocli 4.7.0 + + com.jcabi + jcabi-manifests + + @@ -197,6 +202,7 @@ SOFTWARE. org.eolang.dejump.Main + ${project.version} diff --git a/src/main/java/org/eolang/dejump/Main.java b/src/main/java/org/eolang/dejump/Main.java index 283f63a..41f6434 100644 --- a/src/main/java/org/eolang/dejump/Main.java +++ b/src/main/java/org/eolang/dejump/Main.java @@ -23,6 +23,7 @@ */ package org.eolang.dejump; +import com.jcabi.manifests.Manifests; import java.io.File; import java.io.IOException; import java.util.concurrent.Callable; @@ -34,10 +35,12 @@ * @since 0.0.1 * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) */ -@CommandLine.Command(name = "dejump", +@CommandLine.Command( + name = "dejump", mixinStandardHelpOptions = true, - version = "Version 0.0.1", - description = "Replaces objects GOTO with semantically equivalent") + description = "Replaces objects GOTO with semantically equivalent", + versionProvider = Main.Version.class +) public final class Main implements Callable { /** @@ -68,4 +71,22 @@ public Integer call() throws IOException { public static void main(final String[] args) { new CommandLine(new Main()).execute(args); } + + /** + * Version. + * @since 0.0.2 + */ + static final class Version implements CommandLine.IVersionProvider { + @Override + public String[] getVersion() { + return new String[]{ + String.format( + "Dejump version is %s\nEO version is %s", + Manifests.read("Dejump-Version"), + Manifests.read("EO-Version") + ), + }; + } + } + }