--- a/bash-completion.sh Thu Jul 22 01:06:14 2021 +0200
+++ b/bash-completion.sh Thu Jul 22 20:01:03 2021 +0200
@@ -59,6 +59,30 @@
"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=(
+ "encoding"
+ "parse-encapsulated"
+ "tree-style"
+ "tree-with-namespaces"
+ "root-name"
+ );
+
+ ENCODINGS=(
+ "BER"
+ "DER"
+ "CER"
+ "PER"
+ "XER"
+ "ASN.1"
+ );
+
+ TREE_STYLES=(
+ "standard"
+ "literal"
+ )
+
if [[ "$w1" == "--relation" && "x$w0" == "x" ]]; then COMPREPLY=("''")
elif [[ "$w1" == "--records" && "x$w0" == "x" ]]; then COMPREPLY=("'/'")
@@ -77,9 +101,13 @@
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=("''")
- elif [[ "$w2" == "--parser-option" && "x$w0" == "x" ]]; then COMPREPLY=("''")
-
+ elif [[ "$w1" == "--parser-option" ]]; then COMPREPLY=($(compgen -W "${PARSER_OPTIONS[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "encoding" ]]; then COMPREPLY=($(compgen -W "${ENCODINGS[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "parse-encapsulated" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "tree-style" ]]; then COMPREPLY=($(compgen -W "${TREE_STYLES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "tree-with-namespaces" ]]; then COMPREPLY=($(compgen -W "${BOOLEAN_VALUES[*]}" -- "$w0"))
+ elif [[ "$w2" == "--parser-option" && "$w1" == "root-name" && "x$w0" == "x" ]]; then COMPREPLY=("'asn1'")
+
else
OPTIONS=(
"--namespace"