author | František Kučera <franta-hg@frantovo.cz> |
Sun, 05 Jun 2022 00:08:52 +0200 | |
branch | v_0 |
changeset 3 | 62ced7c41c67 |
parent 2 | 1a0fbd17db13 |
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_mqtt_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 |
||
3
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
25 |
CONNECTION_OPTIONS=( |
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
26 |
"username" |
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
27 |
"password" |
0 | 28 |
) |
29 |
||
30 |
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
|
3
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
31 |
elif [[ "$w1" == "--connection-string" && "x$w0" == "x" ]]; then COMPREPLY=("'mqtt://localhost:1883'") |
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
32 |
elif [[ "$w1" == "--connection-option" ]]; then COMPREPLY=($(compgen -W "${CONNECTION_OPTIONS[*]}" -- "$w0")) |
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
33 |
elif [[ "$w2" == "--connection-option" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
2 | 34 |
elif [[ "$w1" == "--stream" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
0 | 35 |
else |
36 |
OPTIONS=( |
|
37 |
"--relation" |
|
3
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
38 |
#"--connection-name" |
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
39 |
"--connection-string" |
62ced7c41c67
parse connection string, credentials, check return values
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
40 |
"--connection-option" |
2 | 41 |
"--stream" |
0 | 42 |
) |
43 |
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
|
44 |
fi |
|
45 |
} |
|
46 |
||
47 |
complete -F _relpipe_out_mqtt_completion relpipe-out-mqtt |