author | František Kučera <franta-hg@frantovo.cz> |
Sat, 06 Aug 2022 15:23:40 +0200 | |
branch | v_0 |
changeset 18 | e16fa75135ad |
parent 5 | e57e2a2798b2 |
permissions | -rw-r--r-- |
0 | 1 |
# Relational pipes |
2 |
# Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info) |
|
3 |
# |
|
4 |
# This program is free software: you can redistribute it and/or modify |
|
5 |
# it under the terms of the GNU General Public License as published by |
|
6 |
# the Free Software Foundation, version 3 of the License. |
|
7 |
# |
|
8 |
# This program is distributed in the hope that it will be useful, |
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
# GNU General Public License for more details. |
|
12 |
# |
|
13 |
# You should have received a copy of the GNU General Public License |
|
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
15 |
||
16 |
_relpipe_out_socket_completion() { |
|
17 |
local w0 w1 w2 w3 |
|
18 |
||
19 |
COMPREPLY=() |
|
20 |
w0=${COMP_WORDS[COMP_CWORD]} |
|
21 |
w1=${COMP_WORDS[COMP_CWORD-1]} |
|
22 |
w2=${COMP_WORDS[COMP_CWORD-2]} |
|
23 |
w3=${COMP_WORDS[COMP_CWORD-3]} |
|
24 |
||
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
25 |
CONNECTION_STRINGS=( |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
26 |
"udp://127.0.0.1:64000" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
27 |
"tcp://127.0.0.1:64000" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
28 |
"sctp://127.0.0.1:64000" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
29 |
"uds:///tmp/relpipe.socket" |
0 | 30 |
) |
31 |
||
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
32 |
OPTIONS=( |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
33 |
"protocol" |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
34 |
"role" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
35 |
"mode" |
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
36 |
"host" |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
37 |
"port" |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
38 |
"path" |
18
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
39 |
"delay" |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
40 |
) |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
41 |
|
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
42 |
PROTOCOLS=( |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
43 |
"tcp" |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
44 |
"udp" |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
45 |
"uds" |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
46 |
"sctp" |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
47 |
) |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
48 |
|
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
49 |
ROLES=( |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
50 |
"client" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
51 |
"server" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
52 |
) |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
53 |
|
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
54 |
MODES=( |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
55 |
"stream" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
56 |
"datagram" |
0 | 57 |
) |
58 |
||
18
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
59 |
DELAYS=( |
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
60 |
"100" |
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
61 |
"200" |
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
62 |
"400" |
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
63 |
"800" |
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
64 |
) |
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
65 |
|
0 | 66 |
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
67 |
elif [[ "$w1" == "--connection-string" ]]; then COMPREPLY=($(compgen -W "${CONNECTION_STRINGS[*]}" -- "$w0")) |
5
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
68 |
elif [[ "$w1" == "--connection-option" ]]; then COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
69 |
elif [[ "$w2" == "--connection-option" && "$w1" == "protocol" ]]; then COMPREPLY=($(compgen -W "${PROTOCOLS[*]}" -- "$w0")) |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
70 |
elif [[ "$w2" == "--connection-option" && "$w1" == "role" ]]; then COMPREPLY=($(compgen -W "${ROLES[*]}" -- "$w0")) |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
71 |
elif [[ "$w2" == "--connection-option" && "$w1" == "mode" ]]; then COMPREPLY=($(compgen -W "${MODES[*]}" -- "$w0")) |
e57e2a2798b2
configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents:
4
diff
changeset
|
72 |
elif [[ "$w2" == "--connection-option" && "$w1" == "path" ]]; then COMPREPLY=($(compgen -f -- "$w0")) |
18
e16fa75135ad
UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents:
5
diff
changeset
|
73 |
elif [[ "$w2" == "--connection-option" && "$w1" == "delay" ]]; then COMPREPLY=($(compgen -W "${DELAYS[*]}" -- "$w0")) |
0 | 74 |
else |
75 |
OPTIONS=( |
|
76 |
"--relation" |
|
4
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
77 |
"--connection-string" |
8d036e5e5fcc
configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
78 |
"--connection-option" |
0 | 79 |
) |
80 |
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
|
81 |
fi |
|
82 |
} |
|
83 |
||
84 |
complete -F _relpipe_out_socket_completion relpipe-out-socket |