add --parser-option 'root-name' 'custom-root-element-name': bash-completion.sh v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 06 Dec 2020 16:40:58 +0100
branchv_0
changeset 27 d6d710336e7c
parent 26 84ff7c97bfdc
child 28 3662c567dab9
add --parser-option 'root-name' 'custom-root-element-name': bash-completion.sh
bash-completion.sh
--- a/bash-completion.sh	Sat Dec 05 20:17:27 2020 +0100
+++ b/bash-completion.sh	Sun Dec 06 16:40:58 2020 +0100
@@ -59,6 +59,12 @@
 		"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=(
+		"root-name"
+	);
+
 
 	if   [[ "$w1" == "--relation"                      && "x$w0" == "x" ]];    then COMPREPLY=("''")
 	elif [[ "$w1" == "--records"                       && "x$w0" == "x" ]];    then COMPREPLY=("'/'")
@@ -77,8 +83,8 @@
 	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"                  && "x$w0" == "x" ]];    then COMPREPLY=("''")
 
 	else
 		OPTIONS=(