bash-completion.sh
branchv_0
changeset 8 8730e2d0db0e
parent 7 ff69af3c67a3
child 11 afeb4e096753
equal deleted inserted replaced
7:ff69af3c67a3 8:8730e2d0db0e
    31 	XINCLUDE=(
    31 	XINCLUDE=(
    32 		"true"
    32 		"true"
    33 		"false"
    33 		"false"
    34 	)
    34 	)
    35 
    35 
       
    36 	MODE=(
       
    37 		"string"
       
    38 		"boolean"
       
    39 		"raw-xml"
       
    40 		"line-number"
       
    41 		"xpath"
       
    42 	)
       
    43 
    36 	# FIXME: user must type " and then press TAB otherwise the completion is broken due to the : colon
    44 	# FIXME: user must type " and then press TAB otherwise the completion is broken due to the : colon
    37 	#
    45 	#
    38 	# can be fixed by global modification of environment variable:
    46 	# can be fixed by global modification of environment variable:
    39 	#	COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
    47 	#	COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
    40 	# but it will affect other completions (where : is a separator)
    48 	# but it will affect other completions (where : is a separator)
    49 		"http://www.w3.org/2000/svg"
    57 		"http://www.w3.org/2000/svg"
    50 		"http://www.w3.org/2005/Atom"
    58 		"http://www.w3.org/2005/Atom"
    51 	)
    59 	)
    52 
    60 
    53 
    61 
    54 	if   [[ "$w1" == "--relation"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    62 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    55 	elif [[ "$w1" == "--relation"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    63 	elif [[ "$w1" == "--records"                       && "x$w0" == "x" ]];    then COMPREPLY=("'/'")
    56 	elif [[ "$w1" == "--records"       && "x$w0" == "x" ]];    then COMPREPLY=("'/'")
    64 	elif [[ "$w1" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    57 	elif [[ "$w1" == "--attribute"     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    65 	elif [[ "$w2" == "--attribute"                                      ]];    then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0"))
    58 	elif [[ "$w2" == "--attribute"                      ]];    then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0"))
    66 	elif [[ "$w3" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    59 	elif [[ "$w3" == "--attribute"     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    67 	elif [[ "$w1" == "--namespace"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    60 	elif [[ "$w1" == "--namespace"     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    68 	elif [[ "$w2" == "--namespace"                                      ]];    then COMPREPLY=($(compgen -W "${XMLNS[*]}" -- "$w0"))
    61 	elif [[ "$w2" == "--namespace"                      ]];    then COMPREPLY=($(compgen -W "${XMLNS[*]}" -- "$w0"))
    69 	elif [[ "$w1" == "--xinclude"                                       ]];    then COMPREPLY=($(compgen -W "${XINCLUDE[*]}" -- "$w0"))
    62 	elif [[ "$w1" == "--xinclude"                       ]];    then COMPREPLY=($(compgen -W "${XINCLUDE[*]}" -- "$w0"))
    70 	elif [[ "$w1" == "--mode"                                           ]];    then COMPREPLY=($(compgen -W "${MODE[*]}" -- "$w0"))
       
    71 	elif [[ "$w1" == "--raw-xml-nodelist-wrapper"                       ]];    then COMPREPLY=("'xml'")
       
    72 	elif [[ "$w2" == "--raw-xml-nodelist-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    73 	elif [[ "$w3" == "--raw-xml-nodelist-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    74 
       
    75 	elif [[ "$w1" == "--raw-xml-attribute-wrapper"                       ]];    then COMPREPLY=("'attribute'")
       
    76 	elif [[ "$w2" == "--raw-xml-attribute-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    77 	elif [[ "$w3" == "--raw-xml-attribute-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    63 	else
    78 	else
    64 		OPTIONS=(
    79 		OPTIONS=(
    65 			"--namespace"
    80 			"--namespace"
    66 			"--relation"
    81 			"--relation"
    67 			"--records"
    82 			"--records"
    68 			"--name-is-xpath"
    83 			"--name-is-xpath"
    69 			"--attribute"
    84 			"--attribute"
    70 			"--xinclude"
    85 			"--xinclude"
       
    86 			"--mode"
       
    87 			"--raw-xml-nodelist-wrapper"
       
    88 			"--raw-xml-attribute-wrapper"
    71 		)
    89 		)
    72 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    90 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    73 	fi
    91 	fi
    74 }
    92 }
    75 
    93