bash-completion.sh
branchv_0
changeset 3 610783d70ae9
parent 2 0799eaf338b9
equal deleted inserted replaced
2:0799eaf338b9 3:610783d70ae9
    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_OPTIONS=(
    26 		"string"
    26 		"username"
    27 		"integer"
    27 		"password"
    28 		"boolean"
       
    29 	)
       
    30 
       
    31 	BOOLEAN_VALUES=(
       
    32 		"true"
       
    33 		"false"
       
    34 	)
    28 	)
    35 
    29 
    36 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    30 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    31 	elif [[ "$w1" == "--connection-string"             && "x$w0" == "x" ]];    then COMPREPLY=("'mqtt://localhost:1883'")
       
    32 	elif [[ "$w1" == "--connection-option"                              ]];    then COMPREPLY=($(compgen -W "${CONNECTION_OPTIONS[*]}" -- "$w0"))
       
    33 	elif [[ "$w2" == "--connection-option"             && "x$w0" == "x" ]];    then COMPREPLY=("''")
    37 	elif [[ "$w1" == "--stream"                        && "x$w0" == "x" ]];    then COMPREPLY=("''")
    34 	elif [[ "$w1" == "--stream"                        && "x$w0" == "x" ]];    then COMPREPLY=("''")
    38 	elif [[ "$w1" == "--message-count"                 && "x$w0" == "x" ]];    then COMPREPLY=("1")
    35 	elif [[ "$w1" == "--message-count"                 && "x$w0" == "x" ]];    then COMPREPLY=("1")
    39 	else
    36 	else
    40 		OPTIONS=(
    37 		OPTIONS=(
    41 			"--relation"
    38 			"--relation"
       
    39 			#"--connection-name"
       
    40 			"--connection-string"
       
    41 			"--connection-option"
    42 			"--stream"
    42 			"--stream"
    43 			"--message-count"
    43 			"--message-count"
    44 		)
    44 		)
    45 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    45 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    46 	fi
    46 	fi