1.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java Sat Aug 15 10:44:36 2015 +0200
1.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java Sat Aug 15 10:47:56 2015 +0200
1.3 @@ -47,6 +47,7 @@
1.4 private String databaseName;
1.5 private final Set<String> databaseNamesToTest = new LinkedHashSet<>();
1.6 private final Set<String> databaseNamesToListProperties = new LinkedHashSet<>();
1.7 + private final Set<String> formatterNamesToListProperties = new LinkedHashSet<>();
1.8 private String namePrefix = DEFAULT_NAME_PREFIX;
1.9 private String nameSuffix = DEFAULT_NAME_SUFFIX;
1.10 private String formatterName;
1.11 @@ -202,6 +203,7 @@
1.12 }
1.13
1.14 /**
1.15 + * @param namePrefix
1.16 * @see #getNamePrefix()
1.17 */
1.18 public void setNamePrefix(String namePrefix) {
1.19 @@ -216,6 +218,7 @@
1.20 }
1.21
1.22 /**
1.23 + * @param nameSuffix
1.24 * @see #getNameSuffix()
1.25 */
1.26 public void setNameSuffix(String nameSuffix) {
1.27 @@ -253,7 +256,15 @@
1.28 public void addDatabaseNameToListProperties(String name) {
1.29 databaseNamesToListProperties.add(name);
1.30 }
1.31 -
1.32 +
1.33 + public Set<String> getFormatterNamesToListProperties() {
1.34 + return formatterNamesToListProperties;
1.35 + }
1.36 +
1.37 + public void addFormatterNameToListProperties(String name) {
1.38 + formatterNamesToListProperties.add(name);
1.39 + }
1.40 +
1.41 public SQLCommand getSQLCommand() {
1.42 if (namedParameters.isEmpty()) {
1.43 return new SQLCommandNumbered(sql, numberedParameters);
2.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sat Aug 15 10:44:36 2015 +0200
2.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sat Aug 15 10:47:56 2015 +0200
2.3 @@ -126,6 +126,10 @@
2.4 case Tokens.INFO_FORMATTERS:
2.5 options.addShowInfo(InfoType.FORMATTERS);
2.6 break;
2.7 + case Tokens.INFO_FORMATTER_PROPERTIES:
2.8 + options.addShowInfo(InfoType.FORMATTER_PROPERTIES);
2.9 + options.addFormatterNameToListProperties(fetchNext(args, ++i));
2.10 + break;
2.11 case Tokens.INFO_LICENSE:
2.12 options.addShowInfo(InfoType.LICENSE);
2.13 break;
2.14 @@ -191,6 +195,7 @@
2.15 public static final String INFO_JAVA_PROPERTIES = "--list-java-properties"; // bash-completion:option // help: list of Java system properties
2.16 public static final String INFO_ENVIRONMENT_VARIABLES = "--list-environment-variables"; // bash-completion:option // help: list of environment variables
2.17 public static final String INFO_FORMATTERS = "--list-formatters"; // bash-completion:option // help: print list of available formatters
2.18 + public static final String INFO_FORMATTER_PROPERTIES = "--list-formatter-properties"; // bash-completion:option // help: print list of available formatter properties
2.19 public static final String INFO_TYPES = "--list-types"; // bash-completion:option // help: print list of available data types
2.20 public static final String INFO_JDBC_DRIVERS = "--list-jdbc-drivers"; // bash-completion:option // help: list of available JDBC drivers
2.21 public static final String INFO_JDBC_PROPERTIES = "--list-jdbc-properties"; // bash-completion:option // help: list of available JDBC properties for given database
3.1 --- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sat Aug 15 10:44:36 2015 +0200
3.2 +++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sat Aug 15 10:47:56 2015 +0200
3.3 @@ -176,6 +176,12 @@
3.4 }
3.5 }
3.6
3.7 + private void listFormatterProperties() {
3.8 + for (String name : options.getFormatterNamesToListProperties()) {
3.9 + log.log(Level.SEVERE, "TODO: list formatter properties for {0}", name);
3.10 + }
3.11 + }
3.12 +
3.13 public void listTypes() throws FormatterException, ConfigurationException {
3.14 ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("code", SQLType.INTEGER));
3.15 List<Object[]> data = new ArrayList<>();
3.16 @@ -346,16 +352,13 @@
3.17 }
3.18
3.19 for (final String dbName : options.getDatabaseNamesToTest()) {
3.20 - es.submit(new Runnable() {
3.21 - // TODO: Java 8 – lambda
3.22 - @Override
3.23 - public void run() {
3.24 - final Object[] row = testConnection(dbName);
3.25 - synchronized (currentFormatter) {
3.26 - printRow(currentFormatter, row);
3.27 - }
3.28 + es.submit(() -> {
3.29 + final Object[] row = testConnection(dbName);
3.30 + synchronized (currentFormatter) {
3.31 + printRow(currentFormatter, row);
3.32 }
3.33 - });
3.34 + }
3.35 + );
3.36 }
3.37
3.38 es.shutdown();
3.39 @@ -565,6 +568,12 @@
3.40 infoLister.listFormatters();
3.41 }
3.42 },
3.43 + FORMATTER_PROPERTIES {
3.44 + @Override
3.45 + public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
3.46 + infoLister.listFormatterProperties();
3.47 + }
3.48 + },
3.49 TYPES {
3.50 @Override
3.51 public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException {
4.1 --- a/scripts/bash_completion.pl Sat Aug 15 10:44:36 2015 +0200
4.2 +++ b/scripts/bash_completion.pl Sat Aug 15 10:47:56 2015 +0200
4.3 @@ -56,7 +56,7 @@
4.4 return 0
4.5 fi
4.6 ;;
4.7 - --formatter)
4.8 + --formatter | --list-formatter-properties)
4.9 if [ -f '.$formattersFile.' ]; then
4.10 COMPREPLY=( $( compgen -W " $( cat '.$formattersFile.' ) " -- $cur ) )
4.11 else