InfoLister: new listings: --list-java-properties and --list-environment-variables
1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java Sun May 24 18:45:46 2015 +0200
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java Sun May 24 19:10:25 2015 +0200
1.3 @@ -45,14 +45,14 @@
1.4 public static final String DEFAULT_NAME_SUFFIX = "(?=([^\\w]|$))";
1.5 private String sql;
1.6 private String databaseName;
1.7 - private Set<String> databaseNamesToTest = new LinkedHashSet<>();
1.8 - private Set<String> databaseNamesToListProperties = new LinkedHashSet<>();
1.9 + private final Set<String> databaseNamesToTest = new LinkedHashSet<>();
1.10 + private final Set<String> databaseNamesToListProperties = new LinkedHashSet<>();
1.11 private String namePrefix = DEFAULT_NAME_PREFIX;
1.12 private String nameSuffix = DEFAULT_NAME_SUFFIX;
1.13 private String formatterName;
1.14 private boolean batch;
1.15 - private Properties formatterProperties = new Properties();
1.16 - private Properties databaseProperties = new Properties();
1.17 + private final Properties formatterProperties = new Properties();
1.18 + private final Properties databaseProperties = new Properties();
1.19
1.20 public enum MODE {
1.21
2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sun May 24 18:45:46 2015 +0200
2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sun May 24 19:10:25 2015 +0200
2.3 @@ -129,6 +129,12 @@
2.4 case Tokens.INFO_LICENSE:
2.5 options.addShowInfo(InfoType.LICENSE);
2.6 break;
2.7 + case Tokens.INFO_JAVA_PROPERTIES:
2.8 + options.addShowInfo(InfoType.JAVA_PROPERTIES);
2.9 + break;
2.10 + case Tokens.INFO_ENVIRONMENT_VARIABLES:
2.11 + options.addShowInfo(InfoType.ENVIRONMENT_VARIABLES);
2.12 + break;
2.13 case Tokens.INFO_TYPES:
2.14 options.addShowInfo(InfoType.TYPES);
2.15 break;
2.16 @@ -182,6 +188,8 @@
2.17 public static final String INFO_HELP = "--help"; // bash-completion:option // help: print this help
2.18 public static final String INFO_VERSION = "--version"; // bash-completion:option // help: print version info
2.19 public static final String INFO_LICENSE = "--license"; // bash-completion:option // help: print license
2.20 + public static final String INFO_JAVA_PROPERTIES = "--list-java-properties"; // bash-completion:option // help: list of Java system properties
2.21 + public static final String INFO_ENVIRONMENT_VARIABLES = "--list-environment-variables"; // bash-completion:option // help: list of environment variables
2.22 public static final String INFO_FORMATTERS = "--list-formatters"; // bash-completion:option // help: print list of available formatters
2.23 public static final String INFO_TYPES = "--list-types"; // bash-completion:option // help: print list of available data types
2.24 public static final String INFO_JDBC_DRIVERS = "--list-jdbc-drivers"; // bash-completion:option // help: list of available JDBC drivers
3.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sun May 24 18:45:46 2015 +0200
3.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sun May 24 19:10:25 2015 +0200
3.3 @@ -42,6 +42,7 @@
3.4 import java.util.EnumSet;
3.5 import java.util.HashSet;
3.6 import java.util.List;
3.7 +import java.util.Map.Entry;
3.8 import java.util.ServiceLoader;
3.9 import java.util.Set;
3.10 import java.util.concurrent.ExecutorService;
3.11 @@ -88,6 +89,8 @@
3.12 case DATABASES:
3.13 case FORMATTERS:
3.14 case TYPES:
3.15 + case JAVA_PROPERTIES:
3.16 + case ENVIRONMENT_VARIABLES:
3.17 formattinNeeded = true;
3.18 break;
3.19 }
3.20 @@ -116,6 +119,24 @@
3.21 }
3.22 }
3.23
3.24 + private void listJavaProperties() throws FormatterException, ConfigurationException {
3.25 + ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("value", SQLType.VARCHAR));
3.26 + List<Object[]> data = new ArrayList<>();
3.27 + for (Entry<Object, Object> e : System.getProperties().entrySet()) {
3.28 + data.add(new Object[]{e.getKey(), e.getValue()});
3.29 + }
3.30 + printTable(formatter, header, "-- Java system properties", null, data);
3.31 + }
3.32 +
3.33 + private void listEnvironmentVariables() throws FormatterException, ConfigurationException {
3.34 + ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("value", SQLType.VARCHAR));
3.35 + List<Object[]> data = new ArrayList<>();
3.36 + for (Entry<String, String> e : System.getenv().entrySet()) {
3.37 + data.add(new Object[]{e.getKey(), e.getValue()});
3.38 + }
3.39 + printTable(formatter, header, "-- environment variables", null, data);
3.40 + }
3.41 +
3.42 private void listFormatters() throws ConfigurationException, FormatterException {
3.43 ColumnsHeader header = constructHeader(
3.44 new HeaderField("name", SQLType.VARCHAR),
3.45 @@ -497,6 +518,18 @@
3.46 infoLister.printResource(Constants.LICENSE_FILE);
3.47 }
3.48 },
3.49 + JAVA_PROPERTIES {
3.50 + @Override
3.51 + public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
3.52 + infoLister.listJavaProperties();
3.53 + }
3.54 + },
3.55 + ENVIRONMENT_VARIABLES {
3.56 + @Override
3.57 + public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
3.58 + infoLister.listEnvironmentVariables();
3.59 + }
3.60 + },
3.61 FORMATTERS {
3.62 @Override
3.63 public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
4.1 --- a/scripts/help_generator.pl Sun May 24 18:45:46 2015 +0200
4.2 +++ b/scripts/help_generator.pl Sun May 24 19:10:25 2015 +0200
4.3 @@ -32,7 +32,7 @@
4.4 ';
4.5
4.6 while (<>) {
4.7 - print " " . sprintf("%-24s", $1) . "$3\n" if (/"(.*?)".*? \/\/\s*bash-completion:option(\s*\/\/\s*help:(.*))?/);
4.8 + print " " . sprintf("%-32s", $1) . "$3\n" if (/"(.*?)".*? \/\/\s*bash-completion:option(\s*\/\/\s*help:(.*))?/);
4.9 last if (/\/\/\s*help:exit-codes/);
4.10 }
4.11