author | František Kučera <franta-hg@frantovo.cz> |
Sat, 26 Oct 2019 22:32:36 +0200 | |
branch | v_0 |
changeset 18 | 76cbba3f7041 |
child 24 | 884ece10575d |
permissions | -rw-r--r-- |
18
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
# Relational pipes |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
# Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
# |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
# This program is free software: you can redistribute it and/or modify |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
# it under the terms of the GNU General Public License as published by |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
# the Free Software Foundation, version 3 of the License. |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
# |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
# This program is distributed in the hope that it will be useful, |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
# GNU General Public License for more details. |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
# |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
# You should have received a copy of the GNU General Public License |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
|
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
_relpipe_tr_sql_completion() { |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
local w0 w1 w2 |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
COMPREPLY=() |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
w0=${COMP_WORDS[COMP_CWORD]} |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
w1=${COMP_WORDS[COMP_CWORD-1]} |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
w2=${COMP_WORDS[COMP_CWORD-2]} |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
|
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
elif [[ "$w2" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=('"SELECT * FROM "') |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
elif [[ "$w1" == "--parameter" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
elif [[ "$w1" == "--copy" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
elif [[ "$w1" == "--copy-renamed" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
elif [[ "$w2" == "--copy-renamed" && "x$w0" == "x" ]]; then COMPREPLY=("'copy_of_\$0'") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
elif [[ "$w1" == "--file" ]]; then COMPREPLY=($(compgen -f "$w0")) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
elif [[ "$w1" == "--file-keep" ]]; then COMPREPLY=($(compgen -W "true false auto" -- "$w0")) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
else |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
OPTIONS=( |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
"--relation" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
"--parameter" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
"--copy" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
"--copy-renamed" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
"--file" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
"--file-keep" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
fi |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
} |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
|
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
complete -F _relpipe_tr_sql_completion relpipe-tr-sql |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
complete -F _relpipe_tr_sql_completion relpipe-in-sql |