bash-completion.sh
branchv_0
changeset 30 f686bdaeb9e0
parent 15 f4fb07ed8753
child 31 c6527b45fbc2
equal deleted inserted replaced
29:06aaad12c207 30:f686bdaeb9e0
    26 		"string"
    26 		"string"
    27 		"integer"
    27 		"integer"
    28 		"boolean"
    28 		"boolean"
    29 	)
    29 	)
    30 
    30 
    31 	XINCLUDE=(
    31 	BOOLEAN_VALUES=(
    32 		"true"
    32 		"true"
    33 		"false"
    33 		"false"
    34 	)
    34 	)
    35 
    35 
    36 	MODE=(
    36 	MODE=(
    57 		"http://www.w3.org/2000/svg"
    57 		"http://www.w3.org/2000/svg"
    58 		"http://www.w3.org/2005/Atom"
    58 		"http://www.w3.org/2005/Atom"
    59 		"http://docbook.org/ns/docbook"
    59 		"http://docbook.org/ns/docbook"
    60 	)
    60 	)
    61 
    61 
       
    62 	# TODO: introspection: after moving to alt2xml the available options and their values should be provided by the parser
       
    63 
       
    64 	PARSER_OPTIONS=(
       
    65 		"trim-continuing-lines"
       
    66 		"allow-sections"
       
    67 		"allow-section-tags"
       
    68 		"allow-sub-keys"
       
    69 		"comment-separators"
       
    70 		"key-value-separators"
       
    71 		"quotes"
       
    72 		"dialect"
       
    73 		"unescape-basic"
       
    74 		"unescape-java-properties"
       
    75 		"unescape-backspace"
       
    76 	);
       
    77 
       
    78 	DIALECTS=(
       
    79 		"java-properties"
       
    80 	);
       
    81 
    62 
    82 
    63 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    83 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    64 	elif [[ "$w1" == "--records"                       && "x$w0" == "x" ]];    then COMPREPLY=("'/'")
    84 	elif [[ "$w1" == "--records"                       && "x$w0" == "x" ]];    then COMPREPLY=("'/'")
    65 	elif [[ "$w1" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    85 	elif [[ "$w1" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    66 	elif [[ "$w2" == "--attribute"                                      ]];    then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0"))
    86 	elif [[ "$w2" == "--attribute"                                      ]];    then COMPREPLY=($(compgen -W "${DATA_TYPE[*]}" -- "$w0"))
    67 	elif [[ "$w3" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    87 	elif [[ "$w3" == "--attribute"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    68 	elif [[ "$w1" == "--namespace"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    88 	elif [[ "$w1" == "--namespace"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    69 	elif [[ "$w2" == "--namespace"                                      ]];    then COMPREPLY=($(compgen -W "${XMLNS[*]}" -- "$w0"))
    89 	elif [[ "$w2" == "--namespace"                                      ]];    then COMPREPLY=($(compgen -W "${XMLNS[*]}" -- "$w0"))
    70 	elif [[ "$w1" == "--xinclude"                                       ]];    then COMPREPLY=($(compgen -W "${XINCLUDE[*]}" -- "$w0"))
    90 	elif [[ "$w1" == "--xinclude"                                       ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
    71 	elif [[ "$w1" == "--mode"                                           ]];    then COMPREPLY=($(compgen -W "${MODE[*]}" -- "$w0"))
    91 	elif [[ "$w1" == "--mode"                                           ]];    then COMPREPLY=($(compgen -W "${MODE[*]}" -- "$w0"))
    72 	elif [[ "$w1" == "--raw-xml-nodelist-wrapper"                       ]];    then COMPREPLY=("'xml'")
    92 	elif [[ "$w1" == "--raw-xml-nodelist-wrapper"                       ]];    then COMPREPLY=("'xml'")
    73 	elif [[ "$w2" == "--raw-xml-nodelist-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    93 	elif [[ "$w2" == "--raw-xml-nodelist-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    74 	elif [[ "$w3" == "--raw-xml-nodelist-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    94 	elif [[ "$w3" == "--raw-xml-nodelist-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    75 
    95 
    76 	elif [[ "$w1" == "--raw-xml-attribute-wrapper"                       ]];    then COMPREPLY=("'attribute'")
    96 	elif [[ "$w1" == "--raw-xml-attribute-wrapper"                       ]];    then COMPREPLY=("'attribute'")
    77 	elif [[ "$w2" == "--raw-xml-attribute-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    97 	elif [[ "$w2" == "--raw-xml-attribute-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    78 	elif [[ "$w3" == "--raw-xml-attribute-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
    98 	elif [[ "$w3" == "--raw-xml-attribute-wrapper"      && "x$w0" == "x" ]];    then COMPREPLY=("''")
       
    99 
       
   100 	elif [[ "$w1" == "--parser-option"                                  ]];    then COMPREPLY=($(compgen -W "${PARSER_OPTIONS[*]}" -- "$w0"))
       
   101 	elif [[ "$w2" == "--parser-option" && "$w1" == "trim-continuing-lines"                    ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
   102 	elif [[ "$w2" == "--parser-option" && "$w1" == "allow-sections"                           ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
   103 	elif [[ "$w2" == "--parser-option" && "$w1" == "allow-section-tags"                       ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
   104 	elif [[ "$w2" == "--parser-option" && "$w1" == "allow-sub-keys"                           ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
   105 	elif [[ "$w2" == "--parser-option" && "$w1" == "unescape-basic"                           ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
   106 	elif [[ "$w2" == "--parser-option" && "$w1" == "unescape-java-properties"                 ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
   107 	elif [[ "$w2" == "--parser-option" && "$w1" == "unescape-backspace"                       ]];    then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
       
   108 	elif [[ "$w2" == "--parser-option" && "$w1" == "dialect"                                  ]];    then COMPREPLY=($(compgen -W "${DIALECTS[*]}" -- "$w0"))
       
   109 	elif [[ "$w2" == "--parser-option" && "$w1" == "comment-separators"      && "x$w0" == "x" ]];    then COMPREPLY=("'#;'")
       
   110 	elif [[ "$w2" == "--parser-option" && "$w1" == "key-value-separators"    && "x$w0" == "x" ]];    then COMPREPLY=("'=:'")
       
   111 	elif [[ "$w2" == "--parser-option" && "$w1" == "quotes"                  && "x$w0" == "x" ]];    then COMPREPLY=("\$'\"\\''")
       
   112 
    79 	else
   113 	else
    80 		OPTIONS=(
   114 		OPTIONS=(
    81 			"--namespace"
   115 			"--namespace"
       
   116 			"--parser-option"
    82 			"--relation"
   117 			"--relation"
    83 			"--records"
   118 			"--records"
    84 			"--name-is-xpath"
   119 			"--name-is-xpath"
    85 			"--attribute"
   120 			"--attribute"
    86 			"--xinclude"
   121 			"--xinclude"