bash-completion.sh
author František Kučera <franta-hg@frantovo.cz>
Sun, 21 Aug 2022 00:16:50 +0200
branchv_0
changeset 3 2b57c8683ffe
parent 0 e8f15f432efc
permissions -rw-r--r--
synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     1
# Relational pipes
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     2
# Copyright © 2022 František Kučera (Frantovo.cz, GlobalCode.info)
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     3
#
e8f15f432efc 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
e8f15f432efc 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
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
# the Free Software Foundation, version 3 of the License.
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
#
e8f15f432efc 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,
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    11
# GNU General Public License for more details.
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
#
e8f15f432efc 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
e8f15f432efc 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/>.
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    15
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    16
_relpipe_in_socket_completion() {
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    17
	local w0 w1 w2 w3
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    18
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    19
	COMPREPLY=()
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    20
	w0=${COMP_WORDS[COMP_CWORD]}
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    21
	w1=${COMP_WORDS[COMP_CWORD-1]}
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    22
	w2=${COMP_WORDS[COMP_CWORD-2]}
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    23
	w3=${COMP_WORDS[COMP_CWORD-3]}
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    24
3
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    25
	CONNECTION_STRINGS=(
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    26
		"udp://127.0.0.1:64000"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    27
		"tcp://127.0.0.1:64000"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    28
		"sctp://127.0.0.1:64000"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    29
		"uds:///tmp/relpipe.socket"
0
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
	)
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
3
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    32
	OPTIONS=(
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    33
		"protocol"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    34
		"role"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    35
		"mode"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    36
		"host"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    37
		"port"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    38
		"path"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    39
		"delay"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    40
	)
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    41
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    42
	PROTOCOLS=(
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    43
		"tcp"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    44
		"udp"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    45
		"uds"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    46
		"sctp"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    47
	)
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    48
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    49
	ROLES=(
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    50
		"client"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    51
		"server"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    52
	)
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    53
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    54
	MODES=(
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    55
		"stream"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    56
		"datagram"
0
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    57
	)
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    58
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    59
	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    60
	elif [[ "$w1" == "--message-count"                 && "x$w0" == "x" ]];    then COMPREPLY=("1")
3
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    61
	elif [[ "$w1" == "--connection-string"                              ]];    then COMPREPLY=($(compgen -W "${CONNECTION_STRINGS[*]}" -- "$w0"))
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    62
	elif [[ "$w1" == "--connection-option"                              ]];    then COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    63
	elif [[ "$w2" == "--connection-option" && "$w1" == "protocol"       ]];    then COMPREPLY=($(compgen -W "${PROTOCOLS[*]}" -- "$w0"))
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    64
	elif [[ "$w2" == "--connection-option" && "$w1" == "role"           ]];    then COMPREPLY=($(compgen -W "${ROLES[*]}" -- "$w0"))
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    65
	elif [[ "$w2" == "--connection-option" && "$w1" == "mode"           ]];    then COMPREPLY=($(compgen -W "${MODES[*]}" -- "$w0"))
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    66
	elif [[ "$w2" == "--connection-option" && "$w1" == "path"           ]];    then COMPREPLY=($(compgen -f -- "$w0"))
0
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    67
	else
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    68
		OPTIONS=(
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    69
			"--relation"
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    70
			"--message-count"
3
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    71
			"--connection-string"
2b57c8683ffe synchronize interface and common classes with relpipe-out-socket + implement basic UDPServerSocket::receive()
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    72
			"--connection-option"
0
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    73
		)
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
	fi
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
}
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    77
e8f15f432efc establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    78
complete -F _relpipe_in_socket_completion relpipe-in-socket