bash-completion.sh
author František Kučera <franta-hg@frantovo.cz>
Fri, 29 Jul 2022 18:03:49 +0200
branchv_0
changeset 4 8d036e5e5fcc
parent 0 924e354948df
child 5 e57e2a2798b2
permissions -rw-r--r--
configuration: --connection-string --connection-option (role, mode)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
# Relational pipes
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
# Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info)
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
#
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     4
# This program is free software: you can redistribute it and/or modify
924e354948df establish project
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
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
# the Free Software Foundation, version 3 of the License.
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
#
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
# This program is distributed in the hope that it will be useful,
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
# GNU General Public License for more details.
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
#
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
# You should have received a copy of the GNU General Public License
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
# along with this program. If not, see <http://www.gnu.org/licenses/>.
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
_relpipe_out_socket_completion() {
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
	local w0 w1 w2 w3
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
	COMPREPLY=()
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
	w0=${COMP_WORDS[COMP_CWORD]}
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
	w1=${COMP_WORDS[COMP_CWORD-1]}
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
	w2=${COMP_WORDS[COMP_CWORD-2]}
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
	w3=${COMP_WORDS[COMP_CWORD-3]}
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    25
	CONNECTION_STRINGS=(
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    26
		"udp://127.0.0.1:64000"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    27
		"tcp://127.0.0.1:64000"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    28
		"sctp://127.0.0.1:64000"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    29
		"uds:///tmp/relpipe.socket"
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	)
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    32
	CONNECTION_OPTIONS=(
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    33
		"role"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    34
		"mode"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    35
	)
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    36
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    37
	CONNECTION_ROLES=(
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    38
		"client"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    39
		"server"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    40
	)
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    41
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    42
	CONNECTION_MODES=(
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    43
		"stream"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    44
		"datagram"
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    45
	)
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    46
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    47
	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    48
	elif [[ "$w1" == "--connection-string"                              ]];    then COMPREPLY=($(compgen -W "${CONNECTION_STRINGS[*]}" -- "$w0"))
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    49
	elif [[ "$w1" == "--connection-option"                              ]];    then COMPREPLY=($(compgen -W "${CONNECTION_OPTIONS[*]}" -- "$w0"))
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    50
	elif [[ "$w2" == "--connection-option" && "$w1" == "role"           ]];    then COMPREPLY=($(compgen -W "${CONNECTION_ROLES[*]}" -- "$w0"))
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    51
	elif [[ "$w2" == "--connection-option" && "$w1" == "mode"           ]];    then COMPREPLY=($(compgen -W "${CONNECTION_MODES[*]}" -- "$w0"))
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    52
	else
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    53
		OPTIONS=(
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    54
			"--relation"
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    55
			"--connection-string"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    56
			"--connection-option"
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
		)
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	fi
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
}
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    61
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    62
complete -F _relpipe_out_socket_completion relpipe-out-socket