# HG changeset patch # User František Kučera # Date 1439628476 -7200 # Node ID 8dfe037b3274922b006365674bc8e9e4f5abc040 # Parent 1a511d321adef60a7ca4488744c5d1d64d274baf property annotations: grounds for --list-formatter-properties diff -r 1a511d321ade -r 8dfe037b3274 java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java Sat Aug 15 10:44:36 2015 +0200 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIOptions.java Sat Aug 15 10:47:56 2015 +0200 @@ -47,6 +47,7 @@ private String databaseName; private final Set databaseNamesToTest = new LinkedHashSet<>(); private final Set databaseNamesToListProperties = new LinkedHashSet<>(); + private final Set formatterNamesToListProperties = new LinkedHashSet<>(); private String namePrefix = DEFAULT_NAME_PREFIX; private String nameSuffix = DEFAULT_NAME_SUFFIX; private String formatterName; @@ -202,6 +203,7 @@ } /** + * @param namePrefix * @see #getNamePrefix() */ public void setNamePrefix(String namePrefix) { @@ -216,6 +218,7 @@ } /** + * @param nameSuffix * @see #getNameSuffix() */ public void setNameSuffix(String nameSuffix) { @@ -253,7 +256,15 @@ public void addDatabaseNameToListProperties(String name) { databaseNamesToListProperties.add(name); } - + + public Set getFormatterNamesToListProperties() { + return formatterNamesToListProperties; + } + + public void addFormatterNameToListProperties(String name) { + formatterNamesToListProperties.add(name); + } + public SQLCommand getSQLCommand() { if (namedParameters.isEmpty()) { return new SQLCommandNumbered(sql, numberedParameters); diff -r 1a511d321ade -r 8dfe037b3274 java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java --- a/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sat Aug 15 10:44:36 2015 +0200 +++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIParser.java Sat Aug 15 10:47:56 2015 +0200 @@ -126,6 +126,10 @@ case Tokens.INFO_FORMATTERS: options.addShowInfo(InfoType.FORMATTERS); break; + case Tokens.INFO_FORMATTER_PROPERTIES: + options.addShowInfo(InfoType.FORMATTER_PROPERTIES); + options.addFormatterNameToListProperties(fetchNext(args, ++i)); + break; case Tokens.INFO_LICENSE: options.addShowInfo(InfoType.LICENSE); break; @@ -191,6 +195,7 @@ public static final String INFO_JAVA_PROPERTIES = "--list-java-properties"; // bash-completion:option // help: list of Java system properties public static final String INFO_ENVIRONMENT_VARIABLES = "--list-environment-variables"; // bash-completion:option // help: list of environment variables public static final String INFO_FORMATTERS = "--list-formatters"; // bash-completion:option // help: print list of available formatters + public static final String INFO_FORMATTER_PROPERTIES = "--list-formatter-properties"; // bash-completion:option // help: print list of available formatter properties public static final String INFO_TYPES = "--list-types"; // bash-completion:option // help: print list of available data types public static final String INFO_JDBC_DRIVERS = "--list-jdbc-drivers"; // bash-completion:option // help: list of available JDBC drivers public static final String INFO_JDBC_PROPERTIES = "--list-jdbc-properties"; // bash-completion:option // help: list of available JDBC properties for given database diff -r 1a511d321ade -r 8dfe037b3274 java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java --- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sat Aug 15 10:44:36 2015 +0200 +++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sat Aug 15 10:47:56 2015 +0200 @@ -176,6 +176,12 @@ } } + private void listFormatterProperties() { + for (String name : options.getFormatterNamesToListProperties()) { + log.log(Level.SEVERE, "TODO: list formatter properties for {0}", name); + } + } + public void listTypes() throws FormatterException, ConfigurationException { ColumnsHeader header = constructHeader(new HeaderField("name", SQLType.VARCHAR), new HeaderField("code", SQLType.INTEGER)); List data = new ArrayList<>(); @@ -346,16 +352,13 @@ } for (final String dbName : options.getDatabaseNamesToTest()) { - es.submit(new Runnable() { - // TODO: Java 8 – lambda - @Override - public void run() { - final Object[] row = testConnection(dbName); - synchronized (currentFormatter) { - printRow(currentFormatter, row); - } + es.submit(() -> { + final Object[] row = testConnection(dbName); + synchronized (currentFormatter) { + printRow(currentFormatter, row); } - }); + } + ); } es.shutdown(); @@ -565,6 +568,12 @@ infoLister.listFormatters(); } }, + FORMATTER_PROPERTIES { + @Override + public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException { + infoLister.listFormatterProperties(); + } + }, TYPES { @Override public void showInfo(InfoLister infoLister) throws FormatterException, ConfigurationException { diff -r 1a511d321ade -r 8dfe037b3274 scripts/bash_completion.pl --- a/scripts/bash_completion.pl Sat Aug 15 10:44:36 2015 +0200 +++ b/scripts/bash_completion.pl Sat Aug 15 10:47:56 2015 +0200 @@ -56,7 +56,7 @@ return 0 fi ;; - --formatter) + --formatter | --list-formatter-properties) if [ -f '.$formattersFile.' ]; then COMPREPLY=( $( compgen -W " $( cat '.$formattersFile.' ) " -- $cur ) ) else