bash-completion.sh
branchv_0
changeset 25 98be80d2e65b
parent 24 c69670b7b4ef
child 26 88e566898f8f
equal deleted inserted replaced
24:c69670b7b4ef 25:98be80d2e65b
    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 	BOOLEAN_VALUES=(
       
    26 		"true"
       
    27 		"false"
       
    28 	)
       
    29 
       
    30 	ENTITY_VALUES=(
       
    31 		"relation"
       
    32 		"attribute"
       
    33 		"value"
       
    34 	)
    25 
    35 
    26 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("'.*'")
    36 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("'.*'")
    27 	elif [[ "$w1" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("'.*'")
    37 	elif [[ "$w1" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("'.*'")
    28 	elif [[ "$w1" == "--pattern"                       && "x$w0" == "x" ]];    then COMPREPLY=("''")
    38 	elif [[ "$w1" == "--pattern"                       && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    39 	elif [[ "$w1" == "--case-sensitive"                                 ]];    then COMPREPLY=($(compgen -W "${ENTITY_VALUES[*]}"  -- "$w0"))
       
    40 	elif [[ "$w2" == "--case-sensitive"                                 ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
    41 	elif [[ "$w1" == "--invert-match"                                   ]];    then COMPREPLY=($(compgen -W "${ENTITY_VALUES[*]}"  -- "$w0"))
       
    42 	elif [[ "$w2" == "--invert-match"                                   ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
    29 	else
    43 	else
    30 		OPTIONS=(
    44 		OPTIONS=(
    31 			"--relation"
    45 			"--relation"
    32 			"--attribute"
    46 			"--attribute"
    33 			"--pattern"
    47 			"--pattern"
       
    48 			"--case-sensitive"
       
    49 			"--invert-match"
    34 		)
    50 		)
    35 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    51 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    36 	fi
    52 	fi
    37 }
    53 }
    38 
    54