Skip to content

Commit

Permalink
feat: 'tgsql --version': Added service message version
Browse files Browse the repository at this point in the history
  • Loading branch information
hishidama committed Nov 28, 2023
1 parent 5867652 commit 59b54f6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/cli/src/main/java/com/tsurugidb/console/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.IOException;
import java.io.StringReader;
import java.nio.file.Files;
import java.util.stream.Collectors;

import org.jline.utils.Log;
import org.slf4j.Logger;
Expand All @@ -27,6 +28,7 @@
import com.tsurugidb.console.cli.repl.jline.ReplJLineTerminal;
import com.tsurugidb.console.core.ScriptRunner;
import com.tsurugidb.console.core.util.TanzawaVersion;
import com.tsurugidb.tsubakuro.client.ServiceClientCollector;
import com.tsurugidb.tsubakuro.util.TsubakuroVersion;

/**
Expand Down Expand Up @@ -129,6 +131,8 @@ private static void printVersion() {
System.out.println();
String tsubakuroVersion = getVersion("tsubakuroVersion", () -> TsubakuroVersion.getBuildVersion("session"));
System.out.printf("Tsubakuro: %s%n", tsubakuroVersion);
String serviceMessageVersion = getServiceMessageVersion();
System.out.printf(" service message version: %s%n", serviceMessageVersion);
String jvmVersion = getVersion("jvmVersion", () -> System.getProperty("java.vm.version"));
String javaHome = getVersion("javaHome", () -> System.getProperty("java.home"));
System.out.printf("JVM: %s (%s)%n", jvmVersion, javaHome);
Expand All @@ -148,6 +152,16 @@ private static String getVersion(String title, StringSupplier supplier) {
}
}

private static String getServiceMessageVersion() {
try {
var classList = ServiceClientCollector.collect(false);
return classList.stream().flatMap(c -> ServiceClientCollector.findServiceMessageVersion(c).stream()).collect(Collectors.joining(", "));
} catch (Exception e) {
Log.debug("getServiceMessageVersion error", e);
return "N/A";
}
}

private static void executeConsole(JCommander commander, CliArgument argument) throws Exception {
ReplCvKey.registerKey();

Expand Down

0 comments on commit 59b54f6

Please sign in to comment.