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