scripts/bash-completion.sh
author František Kučera <franta-hg@frantovo.cz>
Sun, 15 Nov 2020 20:20:39 +0100
changeset 116 94081a55bf41
parent 112 bf2240a0471d
permissions -rw-r--r--
Added tag v0.2 for changeset 96e1125c8500
     1 # Alt2XML
     2 # Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info)
     3 #
     4 # This program is free software: you can redistribute it and/or modify
     5 # it under the terms of the GNU General Public License as published by
     6 # the Free Software Foundation, version 3 of the License.
     7 #
     8 # This program is distributed in the hope that it will be useful,
     9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
    10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    11 # GNU General Public License for more details.
    12 #
    13 # You should have received a copy of the GNU General Public License
    14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
    15 
    16 _alt2xml_completion() {
    17 	local w0 w1 w2 w3
    18 
    19 	COMPREPLY=()
    20 	w0=${COMP_WORDS[COMP_CWORD]}
    21 	w1=${COMP_WORDS[COMP_CWORD-1]}
    22 	w2=${COMP_WORDS[COMP_CWORD-2]}
    23 	w3=${COMP_WORDS[COMP_CWORD-3]}
    24 
    25 	BOOLEAN=(
    26 		"true"
    27 		"false"
    28 	)
    29 
    30 	ACTION=(
    31 		"xml"
    32 		"xpath"
    33 		"xslt"
    34 	)
    35 
    36 
    37 	if   [[ "$w1" == "--input-file"	                                    ]];    then compopt -o default; COMPREPLY=()
    38 	elif [[ "$w1" == "--system-id"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    39 	elif [[ "$w1" == "--input-url"                     && "x$w0" == "x" ]];    then COMPREPLY=("''")
    40 	elif [[ "$w1" == "--reader-property"               && "x$w0" == "x" ]];    then COMPREPLY=("''")
    41 	elif [[ "$w2" == "--reader-property"               && "x$w0" == "x" ]];    then COMPREPLY=("''")
    42 	elif [[ "$w1" == "--reader-feature"                && "x$w0" == "x" ]];    then COMPREPLY=("''")
    43 	elif [[ "$w2" == "--reader-feature"                && "x$w0" == "x" ]];    then COMPREPLY=("''")
    44 	elif [[ "$w1" == "--reader-namespace-aware"                         ]];    then COMPREPLY=($(compgen -W "${BOOLEAN[*]}" -- "$w0"))
    45 	elif [[ "$w1" == "--action"                                         ]];    then COMPREPLY=($(compgen -W "${ACTION[*]}"  -- "$w0"))
    46 	elif [[ "$w1" == "--action-property"               && "x$w0" == "x" ]];    then COMPREPLY=("''")
    47 	elif [[ "$w2" == "--action-property"               && "x$w0" == "x" ]];    then COMPREPLY=("''")
    48 	elif [[ "$w1" == "--"                              && "x$w0" == "x" ]];    then COMPREPLY=("''")
    49 	else
    50 		OPTIONS=(
    51 			"--input-file"
    52 			"--input-stdin"
    53 			"--system-id"
    54 			"--input-url"
    55 			"--reader-property"
    56 			"--reader-feature"
    57 			"--reader-namespace-aware"
    58 			"--action"
    59 			"--action-property"
    60 			"--"
    61 		)
    62 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    63 	fi
    64 }
    65 
    66 complete -F _alt2xml_completion alt2xml