--- a/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Sun Aug 16 01:25:01 2015 +0200
+++ b/java/sql-dk/src/info/globalcode/sql/dk/CLIStarter.java Sun Aug 16 01:40:44 2015 +0200
@@ -239,7 +239,7 @@
}
}
- private void writeBashCompletionHelperFileForFormatterProperties(File formattersDir) throws ClassNotFoundException {
+ private void writeBashCompletionHelperFileForFormatterProperties(File formattersDir) throws ClassNotFoundException, FileNotFoundException {
if (Constants.CONFIG_FILE.lastModified() > formattersDir.lastModified()) {
// TODO: delete old directory
formattersDir.mkdir();
@@ -250,12 +250,20 @@
Class<Formatter> formatterClass = (Class<Formatter>) Class.forName(fd.getClassName());
List<Class<? extends Formatter>> hierarchy = Functions.getClassHierarchy(formatterClass, Formatter.class);
Collections.reverse(hierarchy);
- hierarchy.stream().forEach((c) -> {
+ for (Class<? extends Formatter> c : hierarchy) {
for (PropertyDeclaration p : Functions.getPropertyDeclarations(c)) {
File propertyDir = new File(formatterDir, p.name());
propertyDir.mkdir();
+ File choicesFile = new File(propertyDir, "choices");
+ try (PrintWriter fw = new PrintWriter(choicesFile)) {
+ // TODO: refactor, move
+ if (p.type() == Boolean.class) {
+ fw.println("true");
+ fw.println("false");
+ }
+ }
}
- });
+ }
}
log.log(Level.FINE, "Bash completion helper files was written in: {0}", formattersDir);
} else {