bash-completion.sh
branchv_0
changeset 3 2b57c8683ffe
parent 0 e8f15f432efc
equal deleted inserted replaced
2:2665ab0bcf44 3:2b57c8683ffe
    20 	w0=${COMP_WORDS[COMP_CWORD]}
    20 	w0=${COMP_WORDS[COMP_CWORD]}
    21 	w1=${COMP_WORDS[COMP_CWORD-1]}
    21 	w1=${COMP_WORDS[COMP_CWORD-1]}
    22 	w2=${COMP_WORDS[COMP_CWORD-2]}
    22 	w2=${COMP_WORDS[COMP_CWORD-2]}
    23 	w3=${COMP_WORDS[COMP_CWORD-3]}
    23 	w3=${COMP_WORDS[COMP_CWORD-3]}
    24 
    24 
    25 	DATA_TYPE=(
    25 	CONNECTION_STRINGS=(
    26 		"string"
    26 		"udp://127.0.0.1:64000"
    27 		"integer"
    27 		"tcp://127.0.0.1:64000"
    28 		"boolean"
    28 		"sctp://127.0.0.1:64000"
       
    29 		"uds:///tmp/relpipe.socket"
    29 	)
    30 	)
    30 
    31 
    31 	BOOLEAN_VALUES=(
    32 	OPTIONS=(
    32 		"true"
    33 		"protocol"
    33 		"false"
    34 		"role"
       
    35 		"mode"
       
    36 		"host"
       
    37 		"port"
       
    38 		"path"
       
    39 		"delay"
       
    40 	)
       
    41 
       
    42 	PROTOCOLS=(
       
    43 		"tcp"
       
    44 		"udp"
       
    45 		"uds"
       
    46 		"sctp"
       
    47 	)
       
    48 
       
    49 	ROLES=(
       
    50 		"client"
       
    51 		"server"
       
    52 	)
       
    53 
       
    54 	MODES=(
       
    55 		"stream"
       
    56 		"datagram"
    34 	)
    57 	)
    35 
    58 
    36 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    59 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    37 	elif [[ "$w1" == "--unlink-on-close"                                ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
    38 	elif [[ "$w1" == "--queue"                         && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    39 	elif [[ "$w1" == "--message-count"                 && "x$w0" == "x" ]];    then COMPREPLY=("1")
    60 	elif [[ "$w1" == "--message-count"                 && "x$w0" == "x" ]];    then COMPREPLY=("1")
       
    61 	elif [[ "$w1" == "--connection-string"                              ]];    then COMPREPLY=($(compgen -W "${CONNECTION_STRINGS[*]}" -- "$w0"))
       
    62 	elif [[ "$w1" == "--connection-option"                              ]];    then COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
       
    63 	elif [[ "$w2" == "--connection-option" && "$w1" == "protocol"       ]];    then COMPREPLY=($(compgen -W "${PROTOCOLS[*]}" -- "$w0"))
       
    64 	elif [[ "$w2" == "--connection-option" && "$w1" == "role"           ]];    then COMPREPLY=($(compgen -W "${ROLES[*]}" -- "$w0"))
       
    65 	elif [[ "$w2" == "--connection-option" && "$w1" == "mode"           ]];    then COMPREPLY=($(compgen -W "${MODES[*]}" -- "$w0"))
       
    66 	elif [[ "$w2" == "--connection-option" && "$w1" == "path"           ]];    then COMPREPLY=($(compgen -f -- "$w0"))
    40 	else
    67 	else
    41 		OPTIONS=(
    68 		OPTIONS=(
    42 			"--relation"
    69 			"--relation"
    43 			"--unlink-on-close"
       
    44 			"--queue"
       
    45 			"--message-count"
    70 			"--message-count"
       
    71 			"--connection-string"
       
    72 			"--connection-option"
    46 		)
    73 		)
    47 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    74 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    48 	fi
    75 	fi
    49 }
    76 }
    50 
    77