1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scripts/bash_completion.pl Fri Dec 27 17:51:05 2013 +0100
1.3 @@ -0,0 +1,68 @@
1.4 +#!/usr/bin/perl
1.5 +
1.6 +# Parses Java source code from STDIN and generates script for BASH completion
1.7 +# Input (in this order):
1.8 +# info/globalcode/sql/dk/Constants.java
1.9 +# info/globalcode/sql/dk/formatting/*
1.10 +# info/globalcode/sql/dk/CLIParser.java
1.11 +
1.12 +use strict;
1.13 +use warnings;
1.14 +
1.15 +my $configDir = "~";
1.16 +
1.17 +while (<>) {
1.18 + if (/"(.*?)".*? \/\/\s*bash-completion:dir/) {
1.19 + $configDir .= "/$1";
1.20 + last;
1.21 + }
1.22 +}
1.23 +
1.24 +print 'have sql-dk &&
1.25 +_sql_dk()
1.26 +{
1.27 + local cur prev
1.28 +
1.29 + COMPREPLY=()
1.30 + cur=${COMP_WORDS[COMP_CWORD]}
1.31 + prev=${COMP_WORDS[COMP_CWORD-1]}
1.32 +
1.33 + case "$prev" in
1.34 + --db)
1.35 + COMPREPLY=( $( echo "TODO_DATABASE_NAMES" ) );
1.36 + # ' . $configDir .'
1.37 + return 0
1.38 + ;;
1.39 + --formatter)
1.40 + COMPREPLY=( $( compgen -W "
1.41 +';
1.42 +
1.43 +while (<>) {
1.44 + if (/"(.*?)".*? \/\/\s*bash-completion:formatter/) {
1.45 + print " $1\n";
1.46 + }
1.47 + last if (/\/\/\s*bash-completion:options/);
1.48 +}
1.49 +
1.50 +
1.51 +print ' " -- $cur ) );
1.52 + return 0
1.53 + ;;
1.54 + esac;
1.55 +
1.56 + COMPREPLY=( $( compgen -W "
1.57 +';
1.58 +
1.59 +while (<>) {
1.60 + if (/"(.*?)".*? \/\/\s*bash-completion:option/) {
1.61 + print " $1\n";
1.62 + }
1.63 +}
1.64 +
1.65 +print ' " -- $cur ) )
1.66 + return 0
1.67 +
1.68 +}
1.69 +
1.70 +complete -F _sql_dk sql-dk
1.71 +';