--- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sun Jan 05 00:17:27 2014 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java Sun Jan 05 00:49:01 2014 +0100
@@ -59,27 +59,32 @@
public void showInfo() throws ConfigurationException, FormatterException {
EnumSet<InfoType> commands = options.getShowInfo();
+ boolean formattinNeeded = false;
+
for (InfoType infoType : commands) {
switch (infoType) {
- // only these need formatted output
case CONNECTION:
case DATABASES:
case FORMATTERS:
case TYPES:
- try (Formatter f = getFormatter()) {
- formatter = f;
- formatter.writeStartBatch();
- formatter.writeStartDatabase(new DatabaseDefinition());
- showInfos(commands);
- formatter.writeEndDatabase();
- formatter.writeEndBatch();
- formatter.close();
- }
+ formattinNeeded = true;
break;
- default:
- showInfos(commands);
}
}
+
+ if (formattinNeeded) {
+ try (Formatter f = getFormatter()) {
+ formatter = f;
+ formatter.writeStartBatch();
+ formatter.writeStartDatabase(new DatabaseDefinition());
+ showInfos(commands);
+ formatter.writeEndDatabase();
+ formatter.writeEndBatch();
+ formatter.close();
+ }
+ } else {
+ showInfos(commands);
+ }
}
private void showInfos(EnumSet<InfoType> commands) throws ConfigurationException, FormatterException {