author | František Kučera <franta-hg@frantovo.cz> |
Sat, 04 Dec 2021 21:14:53 +0100 | |
branch | v_0 |
changeset 28 | 20bb01607245 |
parent 26 | 576d4965434f |
permissions | -rw-r--r-- |
25
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
# Relational pipes |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
# Copyright © 2021 František Kučera (Frantovo.cz, GlobalCode.info) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
# |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
# This program is free software: you can redistribute it and/or modify |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
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 |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
# the Free Software Foundation, version 3 of the License. |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
# |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
# This program is distributed in the hope that it will be useful, |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
# GNU General Public License for more details. |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
# |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
# You should have received a copy of the GNU General Public License |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
_relpipe_tr_sed_completion() { |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
local w0 w1 w2 w3 |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
COMPREPLY=() |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
w0=${COMP_WORDS[COMP_CWORD]} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
w1=${COMP_WORDS[COMP_CWORD-1]} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
w2=${COMP_WORDS[COMP_CWORD-2]} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
w3=${COMP_WORDS[COMP_CWORD-3]} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
BOOLEAN_VALUES=( |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
"true" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
"false" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
ENTITY_VALUES=( |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
"relation" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
"attribute" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
"value" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
|
26
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
36 |
MODIFY_TARGETS=( |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
37 |
"relation-name" |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
38 |
"attribute-name" |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
39 |
"value" |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
40 |
) |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
41 |
|
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
42 |
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
43 |
elif [[ "$w1" == "--attribute" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
44 |
elif [[ "$w1" == "--value" && "x$w0" == "x" ]]; then COMPREPLY=("'.+'") |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
45 |
elif [[ "$w1" == "--replacement" && "x$w0" == "x" ]]; then COMPREPLY=("'\$0'") |
576d4965434f
new CLI interface: --modify relation-name, --modify attribute-name
František Kučera <franta-hg@frantovo.cz>
parents:
25
diff
changeset
|
46 |
elif [[ "$w1" == "--modify" ]]; then COMPREPLY=($(compgen -W "${MODIFY_TARGETS[*]}" -- "$w0")) |
25
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
47 |
elif [[ "$w1" == "--case-sensitive" ]]; then COMPREPLY=($(compgen -W "${ENTITY_VALUES[*]}" -- "$w0")) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
48 |
elif [[ "$w2" == "--case-sensitive" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
49 |
elif [[ "$w1" == "--invert-match" ]]; then COMPREPLY=($(compgen -W "${ENTITY_VALUES[*]}" -- "$w0")) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
50 |
elif [[ "$w2" == "--invert-match" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0")) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
51 |
else |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
52 |
OPTIONS=( |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
53 |
"--relation" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
54 |
"--attribute" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
55 |
"--value" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
56 |
"--replacement" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
57 |
"--modify" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
58 |
"--case-sensitive" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
59 |
"--invert-match" |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
60 |
) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
61 |
COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0")) |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
62 |
fi |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
63 |
} |
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
64 |
|
0cfbaf5c57a6
new CLI interface: --relation --attribute --value --replacement --case-sensitive --invert-match – first version
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
65 |
complete -F _relpipe_tr_sed_completion relpipe-tr-sed |