equal
deleted
inserted
replaced
37 } |
37 } |
38 } |
38 } |
39 |
39 |
40 my $databasesFile = "$configDir/bash-completion/databases"; |
40 my $databasesFile = "$configDir/bash-completion/databases"; |
41 my $formattersFile = "$configDir/bash-completion/formatters"; |
41 my $formattersFile = "$configDir/bash-completion/formatters"; |
|
42 my $formatterPropertiesDir = "$configDir/bash-completion/formatter-properties"; |
42 |
43 |
43 print '#have sql-dk && |
44 print '#have sql-dk && |
44 _sql_dk() |
45 _sql_dk_bash_completion_find_formatter() { |
45 { |
46 local previous |
46 local cur prev |
47 for token in "$@"; do |
|
48 if [ "x$previous" == "x--formatter" ]; then |
|
49 echo -n "$token"; |
|
50 fi |
|
51 previous="$token"; |
|
52 done |
|
53 } |
|
54 |
|
55 _sql_dk_bash_completion_formatter_property() { |
|
56 if [ -n "$formatter" ]; then # TODO: this does not match formatter name in apostrophes or quotes |
|
57 local formatter_dir='.$formatterPropertiesDir.'/$formatter |
|
58 if [ -d $formatter_dir ]; then |
|
59 ls -1 $formatter_dir; |
|
60 fi |
|
61 fi |
|
62 } |
|
63 |
|
64 _sql_dk_bash_completion_formatter_property_choice() { |
|
65 local property="${COMP_WORDS[COMP_CWORD-1]}"; |
|
66 echo true; |
|
67 echo false; |
|
68 echo "TODO_$property"; |
|
69 # TODO: find choices for the property |
|
70 } |
|
71 |
|
72 _sql_dk_bash_completion() { |
|
73 local cur prev formatter |
47 |
74 |
48 COMPREPLY=() |
75 COMPREPLY=() |
49 cur=${COMP_WORDS[COMP_CWORD]} |
76 cur=${COMP_WORDS[COMP_CWORD]} |
50 prev=${COMP_WORDS[COMP_CWORD-1]} |
77 prev=${COMP_WORDS[COMP_CWORD-1]} |
51 |
78 |
73 |
100 |
74 print ' " -- $cur ) ); |
101 print ' " -- $cur ) ); |
75 fi |
102 fi |
76 return 0 |
103 return 0 |
77 ;; |
104 ;; |
|
105 --formatter-property) |
|
106 formatter=$( _sql_dk_bash_completion_find_formatter "${COMP_WORDS[@]}" ); |
|
107 COMPREPLY=( $( compgen -W "$(_sql_dk_bash_completion_formatter_property )" -- $cur ) ); |
|
108 return 0; |
|
109 ;; |
78 esac; |
110 esac; |
|
111 |
|
112 if [ "x${COMP_WORDS[COMP_CWORD-2]}" == "x--formatter-property" ]; then |
|
113 COMPREPLY=( $( compgen -W "$(_sql_dk_bash_completion_formatter_property_choice )" -- $cur ) ); |
|
114 return 0; |
|
115 fi |
79 |
116 |
80 COMPREPLY=( $( compgen -W " |
117 COMPREPLY=( $( compgen -W " |
81 '; |
118 '; |
82 |
119 |
83 while (<>) { |
120 while (<>) { |
89 print ' " -- $cur ) ) |
126 print ' " -- $cur ) ) |
90 return 0 |
127 return 0 |
91 |
128 |
92 } |
129 } |
93 |
130 |
94 complete -F _sql_dk sql-dk |
131 complete -F _sql_dk_bash_completion sql-dk |
95 '; |
132 '; |