--- a/scripts/bash_completion.pl Fri Dec 27 17:51:05 2013 +0100
+++ b/scripts/bash_completion.pl Fri Dec 27 18:16:45 2013 +0100
@@ -6,6 +6,8 @@
# info/globalcode/sql/dk/formatting/*
# info/globalcode/sql/dk/CLIParser.java
+# TODO: support database/formatter names with spaces
+
use strict;
use warnings;
@@ -18,6 +20,9 @@
}
}
+my $databasesFile = "$configDir/bash-completion/databases";
+my $formattersFile = "$configDir/bash-completion/formatters";
+
print 'have sql-dk &&
_sql_dk()
{
@@ -29,23 +34,28 @@
case "$prev" in
--db)
- COMPREPLY=( $( echo "TODO_DATABASE_NAMES" ) );
- # ' . $configDir .'
- return 0
+ if [ -f '.$databasesFile.' ]; then
+ COMPREPLY=( $( compgen -W " $( cat '.$databasesFile.' ) " -- $cur ) )
+ return 0
+ fi
;;
--formatter)
- COMPREPLY=( $( compgen -W "
+ if [ -f '.$formattersFile.' ]; then
+ COMPREPLY=( $( compgen -W " $( cat '.$formattersFile.' ) " -- $cur ) )
+ else
+ COMPREPLY=( $( compgen -W "
';
while (<>) {
if (/"(.*?)".*? \/\/\s*bash-completion:formatter/) {
- print " $1\n";
+ print " $1\n";
}
last if (/\/\/\s*bash-completion:options/);
}
-print ' " -- $cur ) );
+print ' " -- $cur ) );
+ fi
return 0
;;
esac;