bash-completion.sh
branchv_0
changeset 15 b3239e4ad328
parent 9 14cf28d7681c
child 22 eebc16b7c3e4
equal deleted inserted replaced
14:9ad606c80d3b 15:b3239e4ad328
    11 # GNU General Public License for more details.
    11 # GNU General Public License for more details.
    12 #
    12 #
    13 # You should have received a copy of the GNU General Public License
    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/>.
    14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
    15 
    15 
       
    16 _relpipe_out_jack_completion_ports() {
       
    17 	# TODO: simpler and faster implementation in relpipe-out-jack or relpipe-in-jack C++ code
       
    18 	jack_lsp -tp 2>/dev/null \
       
    19 		| tr -d \\t \
       
    20 		| tr \\n \\0 \
       
    21 		| relpipe-in-cli \
       
    22 			--relation "jack_midi_port" \
       
    23 			--attribute "name" string \
       
    24 			--attribute "properties" string \
       
    25 			--attribute "type" string \
       
    26 			--records-on-stdin true \
       
    27 		| relpipe-tr-grep '.*' 'properties' 'input' \
       
    28 		| relpipe-tr-grep '.*' 'type' 'midi' \
       
    29 		| relpipe-tr-cut '.*' 'name' \
       
    30 		| relpipe-out-nullbyte \
       
    31 		| tr \\0 \\n
       
    32 }
       
    33 
    16 _relpipe_out_jack_completion() {
    34 _relpipe_out_jack_completion() {
    17 	local w0 w1 w2 w3
    35 	local w0 w1 w2 w3
    18 
    36 
    19 	COMPREPLY=()
    37 	COMPREPLY=()
    20 	w0=${COMP_WORDS[COMP_CWORD]}
    38 	w0=${COMP_WORDS[COMP_CWORD]}
    21 	w1=${COMP_WORDS[COMP_CWORD-1]}
    39 	w1=${COMP_WORDS[COMP_CWORD-1]}
    22 	w2=${COMP_WORDS[COMP_CWORD-2]}
    40 	w2=${COMP_WORDS[COMP_CWORD-2]}
    23 	w3=${COMP_WORDS[COMP_CWORD-3]}
    41 	w3=${COMP_WORDS[COMP_CWORD-3]}
    24 
    42 
    25 	BOOLEAN=(
    43 	  if [[ "$w1" == "--jack-client-name"             && "x$w0" == "x" ]];    then COMPREPLY=("'relpipe-out-jack'")
    26 		"true"
    44 	elif [[ "$w1" == "--jack-connect-to-port"                          ]];    then COMPREPLY=($(compgen -W "$(_relpipe_out_jack_completion_ports)" -- "$w0"))
    27 		"false"
       
    28 	)
       
    29 
       
    30 	if   [[ "$w1" == "--TODO"                                          ]];    then COMPREPLY=($(compgen -W "${BOOLEAN[*]}" -- "$w0"))
       
    31 	elif [[ "$w1" == "--jack-client-name"             && "x$w0" == "x" ]];    then COMPREPLY=("'relpipe-out-jack'")
       
    32 	elif [[ "$w1" == "--required-jack-connections"    && "x$w0" == "x" ]];    then COMPREPLY=("1")
    45 	elif [[ "$w1" == "--required-jack-connections"    && "x$w0" == "x" ]];    then COMPREPLY=("1")
    33 	else
    46 	else
    34 		OPTIONS=(
    47 		OPTIONS=(
    35 			"--jack-client-name"
    48 			"--jack-client-name"
       
    49 			"--jack-connect-to-port"
    36 			"--required-jack-connections"
    50 			"--required-jack-connections"
    37 		)
    51 		)
    38 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    52 		COMPREPLY=($(compgen -W "${OPTIONS[*]}" -- "$w0"))
    39 	fi
    53 	fi
    40 }
    54 }