equal
deleted
inserted
replaced
|
1 #!/usr/bin/perl |
|
2 |
|
3 # Parses Java source code from STDIN and generates script for BASH completion |
|
4 # Input (in this order): |
|
5 # info/globalcode/sql/dk/Constants.java |
|
6 # info/globalcode/sql/dk/formatting/* |
|
7 # info/globalcode/sql/dk/CLIParser.java |
|
8 |
|
9 use strict; |
|
10 use warnings; |
|
11 |
|
12 my $configDir = "~"; |
|
13 |
|
14 while (<>) { |
|
15 if (/"(.*?)".*? \/\/\s*bash-completion:dir/) { |
|
16 $configDir .= "/$1"; |
|
17 last; |
|
18 } |
|
19 } |
|
20 |
|
21 print 'have sql-dk && |
|
22 _sql_dk() |
|
23 { |
|
24 local cur prev |
|
25 |
|
26 COMPREPLY=() |
|
27 cur=${COMP_WORDS[COMP_CWORD]} |
|
28 prev=${COMP_WORDS[COMP_CWORD-1]} |
|
29 |
|
30 case "$prev" in |
|
31 --db) |
|
32 COMPREPLY=( $( echo "TODO_DATABASE_NAMES" ) ); |
|
33 # ' . $configDir .' |
|
34 return 0 |
|
35 ;; |
|
36 --formatter) |
|
37 COMPREPLY=( $( compgen -W " |
|
38 '; |
|
39 |
|
40 while (<>) { |
|
41 if (/"(.*?)".*? \/\/\s*bash-completion:formatter/) { |
|
42 print " $1\n"; |
|
43 } |
|
44 last if (/\/\/\s*bash-completion:options/); |
|
45 } |
|
46 |
|
47 |
|
48 print ' " -- $cur ) ); |
|
49 return 0 |
|
50 ;; |
|
51 esac; |
|
52 |
|
53 COMPREPLY=( $( compgen -W " |
|
54 '; |
|
55 |
|
56 while (<>) { |
|
57 if (/"(.*?)".*? \/\/\s*bash-completion:option/) { |
|
58 print " $1\n"; |
|
59 } |
|
60 } |
|
61 |
|
62 print ' " -- $cur ) ) |
|
63 return 0 |
|
64 |
|
65 } |
|
66 |
|
67 complete -F _sql_dk sql-dk |
|
68 '; |