bash-completion.sh
branchv_0
changeset 24 884ece10575d
parent 18 76cbba3f7041
child 34 24c05e69d68f
equal deleted inserted replaced
23:d3bfbce022aa 24:884ece10575d
    19 	COMPREPLY=()
    19 	COMPREPLY=()
    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 
    23 
       
    24 	DATA_TYPE=(
       
    25 		"string"
       
    26 		"integer"
       
    27 		"boolean"
       
    28 	)
    24 
    29 
    25 	if   [[ "$w1" == "--relation"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    30 	if   [[ "$w1" == "--relation"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    26 	elif [[ "$w2" == "--relation"      && "x$w0" == "x" ]];    then COMPREPLY=('"SELECT * FROM "')
    31 	elif [[ "$w2" == "--relation"      && "x$w0" == "x" ]];    then COMPREPLY=('"SELECT * FROM "')
       
    32 	elif [[ "$w1" == "--type-cast"     && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    33 	elif [[ "$w2" == "--type-cast"                      ]];    then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0"))
    27 	elif [[ "$w1" == "--parameter"     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    34 	elif [[ "$w1" == "--parameter"     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    28 	elif [[ "$w1" == "--copy"          && "x$w0" == "x" ]];    then COMPREPLY=("'.+'")
    35 	elif [[ "$w1" == "--copy"          && "x$w0" == "x" ]];    then COMPREPLY=("'.+'")
    29 	elif [[ "$w1" == "--copy-renamed"  && "x$w0" == "x" ]];    then COMPREPLY=("'.+'")
    36 	elif [[ "$w1" == "--copy-renamed"  && "x$w0" == "x" ]];    then COMPREPLY=("'.+'")
    30 	elif [[ "$w2" == "--copy-renamed"  && "x$w0" == "x" ]];    then COMPREPLY=("'copy_of_\$0'")
    37 	elif [[ "$w2" == "--copy-renamed"  && "x$w0" == "x" ]];    then COMPREPLY=("'copy_of_\$0'")
    31 	elif [[ "$w1" == "--file"                           ]];    then COMPREPLY=($(compgen -f "$w0"))
    38 	elif [[ "$w1" == "--file"                           ]];    then COMPREPLY=($(compgen -f "$w0"))
    32 	elif [[ "$w1" == "--file-keep"                      ]];    then COMPREPLY=($(compgen -W "true false auto" -- "$w0"))
    39 	elif [[ "$w1" == "--file-keep"                      ]];    then COMPREPLY=($(compgen -W "true false auto" -- "$w0"))
    33 	else
    40 	else
    34 		OPTIONS=(
    41 		OPTIONS=(
    35 			"--relation"
    42 			"--relation"
       
    43 			"--type-cast"
    36 			"--parameter"
    44 			"--parameter"
    37 			"--copy"
    45 			"--copy"
    38 			"--copy-renamed"
    46 			"--copy-renamed"
    39 			"--file"
    47 			"--file"
    40 			"--file-keep"
    48 			"--file-keep"