bash-completion.sh
author František Kučera <franta-hg@frantovo.cz>
Thu, 18 Aug 2022 03:39:55 +0200
branchv_0
changeset 22 9a7c42cca24b
parent 18 e16fa75135ad
permissions -rw-r--r--
SCTP: sendmsg()
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
5
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    32
	OPTIONS=(
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    33
		"protocol"
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    34
		"role"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    35
		"mode"
5
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    36
		"host"
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    37
		"port"
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    38
		"path"
18
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    39
		"delay"
4
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
5
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    42
	PROTOCOLS=(
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    43
		"tcp"
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    44
		"udp"
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    45
		"uds"
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    46
		"sctp"
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    47
	)
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    48
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    49
	ROLES=(
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    50
		"client"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    51
		"server"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    52
	)
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    53
5
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    54
	MODES=(
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    55
		"stream"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    56
		"datagram"
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
18
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    59
	DELAYS=(
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    60
		"100"
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    61
		"200"
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    62
		"400"
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    63
		"800"
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    64
	)
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    65
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    66
	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
    67
	elif [[ "$w1" == "--connection-string"                              ]];    then COMPREPLY=($(compgen -W "${CONNECTION_STRINGS[*]}" -- "$w0"))
5
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    68
	elif [[ "$w1" == "--connection-option"                              ]];    then COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    69
	elif [[ "$w2" == "--connection-option" && "$w1" == "protocol"       ]];    then COMPREPLY=($(compgen -W "${PROTOCOLS[*]}" -- "$w0"))
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    70
	elif [[ "$w2" == "--connection-option" && "$w1" == "role"           ]];    then COMPREPLY=($(compgen -W "${ROLES[*]}" -- "$w0"))
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    71
	elif [[ "$w2" == "--connection-option" && "$w1" == "mode"           ]];    then COMPREPLY=($(compgen -W "${MODES[*]}" -- "$w0"))
e57e2a2798b2 configuration: protocol, role, mode, host, port, path
František Kučera <franta-hg@frantovo.cz>
parents: 4
diff changeset
    72
	elif [[ "$w2" == "--connection-option" && "$w1" == "path"           ]];    then COMPREPLY=($(compgen -f -- "$w0"))
18
e16fa75135ad UDP: add delay option
František Kučera <franta-hg@frantovo.cz>
parents: 5
diff changeset
    73
	elif [[ "$w2" == "--connection-option" && "$w1" == "delay"          ]];    then COMPREPLY=($(compgen -W "${DELAYS[*]}" -- "$w0"))
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    74
	else
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    75
		OPTIONS=(
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    76
			"--relation"
4
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    77
			"--connection-string"
8d036e5e5fcc configuration: --connection-string --connection-option (role, mode)
František Kučera <franta-hg@frantovo.cz>
parents: 0
diff changeset
    78
			"--connection-option"
0
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    79
		)
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    80
		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    81
	fi
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    82
}
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    83
924e354948df establish project
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    84
complete -F _relpipe_out_socket_completion relpipe-out-socket