bash-completion.sh
author František Kučera <franta-hg@frantovo.cz>
Fri, 25 Sep 2020 02:04:25 +0200
branchv_0
changeset 33 5bc2dfd26dd8
parent 27 f5a944fa7a4f
permissions -rw-r--r--
DEPRECATED: relpipe-tr-guile.cpp → relpipe-tr-scheme.cpp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
# Relational pipes
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
# Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
#
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
# This program is free software: you can redistribute it and/or modify
f5a944fa7a4f bash-completion script
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
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
# the Free Software Foundation, version 3 of the License.
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
#
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
# This program is distributed in the hope that it will be useful,
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
# GNU General Public License for more details.
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
#
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
# You should have received a copy of the GNU General Public License
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
_relpipe_tr_guile_completion() {
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
	local w0 w1 w2
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
	COMPREPLY=()
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
	w0=${COMP_WORDS[COMP_CWORD]}
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
	w1=${COMP_WORDS[COMP_CWORD-1]}
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
	w2=${COMP_WORDS[COMP_CWORD-2]}
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
	DATA_TYPE=(
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    25
		"string"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
		"integer"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
		"boolean"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
	)
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	if   [[ "$w1" == "--relation"          && "x$w0" == "x" ]];    then COMPREPLY=("'.*'")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
	elif [[ "$w1" == "--before-records"    && "x$w0" == "x" ]];    then COMPREPLY=("''")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
	elif [[ "$w1" == "--after-records"     && "x$w0" == "x" ]];    then COMPREPLY=("''")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
	elif [[ "$w1" == "--output-attribute"  && "x$w0" == "x" ]];    then COMPREPLY=("''")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
	elif [[ "$w2" == "--output-attribute"                   ]];    then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0"))
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    35
	elif [[ "$w1" == "--define"            && "x$w0" == "x" ]];    then COMPREPLY=("''")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    36
	elif [[ "$w2" == "--define"                             ]];    then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0"))
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    37
	elif [[ "$w3" == "--define"            && "x$w0" == "x" ]];    then COMPREPLY=("''")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    38
	elif [[ "$w1" == "--for-each"          && "x$w0" == "x" ]];    then COMPREPLY=("''")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    39
	elif [[ "$w1" == "--where"             && "x$w0" == "x" ]];    then COMPREPLY=("'(string= \$a \"\")'")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    40
	elif [[ "$w1" == "--has-more-records"  && "x$w0" == "x" ]];    then COMPREPLY=("''")
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    41
	else
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    42
		OPTIONS=(
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    43
			"--relation"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    44
			"--output-attribute"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
			"--input-attributes-append"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
			"--input-attributes-prepend"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
			"--debug-variable-mapping"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    48
			"--before-records"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
			"--after-records"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
			"--for-each"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
			"--where"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
			"--drop"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
			"--define"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
			"--has-more-records"
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    55
		)
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    56
		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	fi
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
}
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
complete -F _relpipe_tr_guile_completion relpipe-tr-guile
f5a944fa7a4f bash-completion script
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
complete -F _relpipe_tr_guile_completion relpipe-in-guile