--- a/bash-completion.sh Sat Nov 28 21:09:18 2020 +0100
+++ b/bash-completion.sh Sun Nov 29 00:30:36 2020 +0100
@@ -28,7 +28,7 @@
"boolean"
)
- XINCLUDE=(
+ BOOLEAN_VALUES=(
"true"
"false"
)
@@ -59,6 +59,26 @@
"http://docbook.org/ns/docbook"
)
+ # TODO: introspection: after moving to alt2xml the available options and their values should be provided by the parser
+
+ PARSER_OPTIONS=(
+ "trim-continuing-lines"
+ "allow-sections"
+ "allow-section-tags"
+ "allow-sub-keys"
+ "comment-separators"
+ "key-value-separators"
+ "quotes"
+ "dialect"
+ "unescape-basic"
+ "unescape-java-properties"
+ "unescape-backspace"
+ );
+
+ DIALECTS=(
+ "java-properties"
+ );
+
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w1" == "--records" && "x$w0" == "x" ]]; then COMPREPLY=("'/'")
@@ -67,7 +87,7 @@
elif [[ "$w3" == "--attribute" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w1" == "--namespace" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w2" == "--namespace" ]]; then COMPREPLY=($(compgen -W "${XMLNS[*]}" -- "$w0"))
- elif [[ "$w1" == "--xinclude" ]]; then COMPREPLY=($(compgen -W "${XINCLUDE[*]}" -- "$w0"))
+ elif [[ "$w1" == "--xinclude" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
elif [[ "$w1" == "--mode" ]]; then COMPREPLY=($(compgen -W "${MODE[*]}" -- "$w0"))
elif [[ "$w1" == "--raw-xml-nodelist-wrapper" ]]; then COMPREPLY=("'xml'")
elif [[ "$w2" == "--raw-xml-nodelist-wrapper" && "x$w0" == "x" ]]; then COMPREPLY=("''")
@@ -76,9 +96,24 @@
elif [[ "$w1" == "--raw-xml-attribute-wrapper" ]]; then COMPREPLY=("'attribute'")
elif [[ "$w2" == "--raw-xml-attribute-wrapper" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w3" == "--raw-xml-attribute-wrapper" && "x$w0" == "x" ]]; then COMPREPLY=("''")
+
+ elif [[ "$w1" == "--parser-option" ]]; then COMPREPLY=($(compgen -W "${PARSER_OPTIONS[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "trim-continuing-lines" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "allow-sections" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "allow-section-tags" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "allow-sub-keys" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "unescape-basic" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "unescape-java-properties" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "unescape-backspace" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "dialect" ]]; then COMPREPLY=($(compgen -W "${DIALECTS[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "comment-separators" && "x$w0" == "x" ]]; then COMPREPLY=("'#;'")
+ elif [[ "$w2" == "--parser-option" && "$w1" == "key-value-separators" && "x$w0" == "x" ]]; then COMPREPLY=("'=:'")
+ elif [[ "$w2" == "--parser-option" && "$w1" == "quotes" && "x$w0" == "x" ]]; then COMPREPLY=("\$'\"\\''")
+
else
OPTIONS=(
"--namespace"
+ "--parser-option"
"--relation"
"--records"
"--name-is-xpath"