author | František Kučera <franta-hg@frantovo.cz> |
Sat, 24 Jul 2021 17:35:27 +0200 | |
branch | v_0 |
changeset 1 | 68a281aefa76 |
parent 0 | 28294b895e5e |
child 9 | 7d309accc639 |
permissions | -rw-r--r-- |
0
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
# Relational pipes |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
# Copyright © 2021 František Kučera (Frantovo.cz, GlobalCode.info) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
# |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
# This program is free software: you can redistribute it and/or modify |
28294b895e5e
project skeleton + configuration
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 |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
# the Free Software Foundation, version 3 of the License. |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
# |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
# This program is distributed in the hope that it will be useful, |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
# GNU General Public License for more details. |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
# |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
# You should have received a copy of the GNU General Public License |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
_relpipe_in_asn1_completion() { |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
local w0 w1 w2 w3 |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
COMPREPLY=() |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
w0=${COMP_WORDS[COMP_CWORD]} |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
w1=${COMP_WORDS[COMP_CWORD-1]} |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
w2=${COMP_WORDS[COMP_CWORD-2]} |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
w3=${COMP_WORDS[COMP_CWORD-3]} |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
BOOLEAN_VALUES=( |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
"true" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
"false" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
# TODO: introspection: after moving to alt2xml the available options and their values should be provided by the parser |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
PARSER_OPTIONS=( |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
"encoding" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
"parse-encapsulated" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
"tree-style" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
"tree-with-namespaces" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
"root-name" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
); |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
ENCODINGS=( |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
"BER" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
"DER" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
"CER" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
"PER" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
45 |
"XER" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
46 |
"ASN.1" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
); |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
MODES=( |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
"relpipe" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
"freeform" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
); |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''") |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
elif [[ "$w1" == "--mode" ]]; then COMPREPLY=($(compgen -W "${MODES[*]}" -- "$w0")) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
elif [[ "$w1" == "--parser-option" ]]; then COMPREPLY=($(compgen -W "${PARSER_OPTIONS[*]}" -- "$w0")) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
elif [[ "$w2" == "--parser-option" && "$w1" == "encoding" ]]; then COMPREPLY=($(compgen -W "${ENCODINGS[*]}" -- "$w0")) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
elif [[ "$w2" == "--parser-option" && "$w1" == "parse-encapsulated" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
else |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
OPTIONS=( |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
"--relation" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
"--mode" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
"--parser-option" |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
66 |
fi |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
67 |
} |
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
68 |
|
28294b895e5e
project skeleton + configuration
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
69 |
complete -F _relpipe_in_asn1_completion relpipe-in-asn1 |