Skip to content

Commit

Permalink
Add option to dump properties on launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed Sep 13, 2023
1 parent 4e0146f commit 3c9b0e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package software.coley.recaf.analytics;

import jakarta.annotation.Nullable;
import org.slf4j.Logger;

import java.io.StringWriter;
Expand Down Expand Up @@ -66,7 +67,7 @@ private static int determineBitness() {
* @param logger
* Logger to dump into.
*/
public static void dump(Logger logger) {
public static void dump(@Nullable Logger logger) {
if (logger != null)
ALL_PROPERTIES.forEach((key, value) ->
logger.debug("{} = {}", key, value));
Expand All @@ -78,7 +79,7 @@ public static void dump(Logger logger) {
* @param writer
* Writer to dump into.
*/
public static void dump(StringWriter writer) {
public static void dump(@Nullable StringWriter writer) {
if (writer != null)
ALL_PROPERTIES.forEach((key, value) ->
writer.append(String.format("%s = %s\n", key, value)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import picocli.CommandLine.Option;
import software.coley.recaf.Bootstrap;
import software.coley.recaf.RecafBuildConfig;
import software.coley.recaf.analytics.SystemInformation;
import software.coley.recaf.services.Service;
import software.coley.recaf.util.StringUtil;

import java.io.File;
import java.io.StringWriter;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
Expand All @@ -36,10 +38,13 @@ public class LaunchCommand implements Callable<Boolean> {
private boolean version;
@Option(names = {"-l", "--listservices"}, description = "Display the version information.")
private boolean listServices;
@Option(names = {"-p", "--listprops"}, description = "Display system properties.")
private boolean dumpProperties;

@Override
public Boolean call() throws Exception {
if (version || listServices)
boolean ret = false;
if (version || listServices || dumpProperties)
System.out.println("======================= RECAF =======================");
if (version) {
System.out.printf("""
Expand All @@ -54,7 +59,7 @@ public Boolean call() throws Exception {
RecafBuildConfig.GIT_DATE,
RecafBuildConfig.GIT_BRANCH
);
return true;
ret = true;
}
if (listServices) {
try {
Expand All @@ -70,9 +75,16 @@ public Boolean call() throws Exception {
System.out.println(StringUtil.traceToString(t));
}
System.out.println("=====================================================");
return true;
ret = true;
}
return false;
if (dumpProperties) {
StringWriter sw = new StringWriter();
SystemInformation.dump(sw);
System.out.println(sw);
System.out.println("=====================================================");
ret = true;
}
return ret;
}

/**
Expand Down

0 comments on commit 3c9b0e6

Please sign in to comment.