author | František Kučera <franta-hg@frantovo.cz> |
Sat, 14 Dec 2019 14:00:36 +0100 | |
branch | v_0 |
changeset 24 | 884ece10575d |
parent 18 | 76cbba3f7041 |
child 34 | 24c05e69d68f |
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 |
|
24
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
24 |
DATA_TYPE=( |
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
25 |
"string" |
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
26 |
"integer" |
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
27 |
"boolean" |
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
28 |
) |
18
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
elif [[ "$w2" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=('"SELECT * FROM "') |
24
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
32 |
elif [[ "$w1" == "--type-cast" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
33 |
elif [[ "$w2" == "--type-cast" ]]; then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0")) |
18
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
elif [[ "$w1" == "--parameter" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
elif [[ "$w1" == "--copy" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
elif [[ "$w1" == "--copy-renamed" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
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
|
38 |
elif [[ "$w1" == "--file" ]]; then COMPREPLY=($(compgen -f "$w0")) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
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
|
40 |
else |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
OPTIONS=( |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
"--relation" |
24
884ece10575d
add --type-cast to allow explicit specification of type for given output attributes
František Kučera <franta-hg@frantovo.cz>
parents:
18
diff
changeset
|
43 |
"--type-cast" |
18
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
"--parameter" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
"--copy" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
"--copy-renamed" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
"--file" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
"--file-keep" |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
fi |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
} |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
|
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
complete -F _relpipe_tr_sql_completion relpipe-tr-sql |
76cbba3f7041
bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
complete -F _relpipe_tr_sql_completion relpipe-in-sql |