author | František Kučera <franta-hg@frantovo.cz> |
Fri, 27 Dec 2013 17:51:05 +0100 | |
branch | v_0 |
changeset 81 | 847c83288d01 |
child 82 | adea6d8d3708 |
permissions | -rwxr-xr-x |
81
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
#!/usr/bin/perl |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
# Parses Java source code from STDIN and generates script for BASH completion |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
# Input (in this order): |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
# info/globalcode/sql/dk/Constants.java |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
# info/globalcode/sql/dk/formatting/* |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
# info/globalcode/sql/dk/CLIParser.java |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
use strict; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
use warnings; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
my $configDir = "~"; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
while (<>) { |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
if (/"(.*?)".*? \/\/\s*bash-completion:dir/) { |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
$configDir .= "/$1"; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
last; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
print 'have sql-dk && |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
_sql_dk() |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
{ |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
local cur prev |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
COMPREPLY=() |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
cur=${COMP_WORDS[COMP_CWORD]} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
prev=${COMP_WORDS[COMP_CWORD-1]} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
case "$prev" in |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
--db) |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
COMPREPLY=( $( echo "TODO_DATABASE_NAMES" ) ); |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
# ' . $configDir .' |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
return 0 |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
;; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
--formatter) |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
COMPREPLY=( $( compgen -W " |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
'; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
while (<>) { |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
if (/"(.*?)".*? \/\/\s*bash-completion:formatter/) { |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
print " $1\n"; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
last if (/\/\/\s*bash-completion:options/); |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
print ' " -- $cur ) ); |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
return 0 |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
;; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
esac; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
COMPREPLY=( $( compgen -W " |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
'; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
while (<>) { |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
if (/"(.*?)".*? \/\/\s*bash-completion:option/) { |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
print " $1\n"; |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
print ' " -- $cur ) ) |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
return 0 |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
} |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
|
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
complete -F _sql_dk sql-dk |
847c83288d01
bash completion: perl + bash + ant for generating completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
'; |