--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/bash_completion.pl Fri Dec 27 17:51:05 2013 +0100
@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+
+# Parses Java source code from STDIN and generates script for BASH completion
+# Input (in this order):
+# info/globalcode/sql/dk/Constants.java
+# info/globalcode/sql/dk/formatting/*
+# info/globalcode/sql/dk/CLIParser.java
+
+use strict;
+use warnings;
+
+my $configDir = "~";
+
+while (<>) {
+ if (/"(.*?)".*? \/\/\s*bash-completion:dir/) {
+ $configDir .= "/$1";
+ last;
+ }
+}
+
+print 'have sql-dk &&
+_sql_dk()
+{
+ local cur prev
+
+ COMPREPLY=()
+ cur=${COMP_WORDS[COMP_CWORD]}
+ prev=${COMP_WORDS[COMP_CWORD-1]}
+
+ case "$prev" in
+ --db)
+ COMPREPLY=( $( echo "TODO_DATABASE_NAMES" ) );
+ # ' . $configDir .'
+ return 0
+ ;;
+ --formatter)
+ COMPREPLY=( $( compgen -W "
+';
+
+while (<>) {
+ if (/"(.*?)".*? \/\/\s*bash-completion:formatter/) {
+ print " $1\n";
+ }
+ last if (/\/\/\s*bash-completion:options/);
+}
+
+
+print ' " -- $cur ) );
+ return 0
+ ;;
+ esac;
+
+ COMPREPLY=( $( compgen -W "
+';
+
+while (<>) {
+ if (/"(.*?)".*? \/\/\s*bash-completion:option/) {
+ print " $1\n";
+ }
+}
+
+print ' " -- $cur ) )
+ return 0
+
+}
+
+complete -F _sql_dk sql-dk
+';