Blame data/bash-completion/completions/gst-inspect-1.0

Packit f546b1
# GStreamer
Packit f546b1
# Copyright (C) 2015 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
Packit f546b1
#
Packit f546b1
# bash/zsh completion support for gst-inspect
Packit f546b1
#
Packit f546b1
# This library is free software; you can redistribute it and/or
Packit f546b1
# modify it under the terms of the GNU Library General Public
Packit f546b1
# License as published by the Free Software Foundation; either
Packit f546b1
# version 2 of the License, or (at your option) any later version.
Packit f546b1
#
Packit f546b1
# This library is distributed in the hope that it will be useful,
Packit f546b1
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit f546b1
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit f546b1
# Library General Public License for more details.
Packit f546b1
#
Packit f546b1
# You should have received a copy of the GNU Library General Public
Packit f546b1
# License along with this library; if not, write to the
Packit f546b1
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit f546b1
# Boston, MA 02110-1301, USA.
Packit f546b1
Packit f546b1
_GST_HELPERDIR="${BASH_SOURCE[0]%/*}/../helpers"
Packit f546b1
Packit f546b1
if [[ ! -d "$_GST_HELPERDIR"  ]]; then
Packit f546b1
	_GST_HELPERDIR="$(pkg-config --variable=bashhelpersdir gstreamer-1.0)"
Packit f546b1
else
Packit f546b1
	_GST_HELPERDIR=`cd "$_GST_HELPERDIR"; pwd`
Packit f546b1
fi
Packit f546b1
Packit f546b1
# Common definitions
Packit f546b1
. "$_GST_HELPERDIR"/gst
Packit f546b1
Packit f546b1
_gst_inspect_all_arguments ()
Packit f546b1
{
Packit f546b1
	_gst_all_arguments gst-inspect-1.0
Packit f546b1
}
Packit f546b1
Packit f546b1
_gst_inspect_all_elements ()
Packit f546b1
{
Packit f546b1
	COMPREPLY=( $(compgen -W "$($_GST_HELPER -l)" -- $cur) )
Packit f546b1
}
Packit f546b1
Packit f546b1
_gstinspect___atleast_version () { _gst_mandatory_argument gst-inspect-1.0; }
Packit f546b1
Packit f546b1
_gstinspect___exists ()
Packit f546b1
{
Packit f546b1
	_gst_inspect_all_elements
Packit f546b1
}
Packit f546b1
Packit f546b1
__inspect_main ()
Packit f546b1
{
Packit f546b1
	local i=1 command function_exists completion_func
Packit f546b1
Packit f546b1
	while [[ $i -ne $COMP_CWORD ]];
Packit f546b1
		do
Packit f546b1
			local var
Packit f546b1
			var="${COMP_WORDS[i]}"
Packit f546b1
			if [[ "$var" == "-"* ]]
Packit f546b1
			then
Packit f546b1
				command="$var"
Packit f546b1
			fi
Packit f546b1
		i=$(($i+1))
Packit f546b1
		done
Packit f546b1
Packit f546b1
	if [[ "$command" == "--gst"* ]]; then
Packit f546b1
		completion_func="_${command//-/_}"
Packit f546b1
	else
Packit f546b1
		completion_func="_gstinspect_${command//-/_}"
Packit f546b1
	fi
Packit f546b1
Packit f546b1
	declare -f $completion_func >/dev/null 2>&1
Packit f546b1
Packit f546b1
	function_exists=$?
Packit f546b1
Packit f546b1
	if [[ "$cur" == "-"* ]]
Packit f546b1
        then
Packit f546b1
		_gst_inspect_all_arguments
Packit f546b1
	elif [ $function_exists -eq 0 ]
Packit f546b1
	then
Packit f546b1
		$completion_func
Packit f546b1
	else
Packit f546b1
		_gst_inspect_all_elements
Packit f546b1
	fi
Packit f546b1
}
Packit f546b1
Packit f546b1
_gst_inspect_func_wrap ()
Packit f546b1
{
Packit f546b1
	local cur prev
Packit f546b1
	cur="${COMP_WORDS[COMP_CWORD]}"
Packit f546b1
	prev="${COMP_WORDS[COMP_CWORD-1]}"
Packit f546b1
	$1
Packit f546b1
}
Packit f546b1
Packit f546b1
# Setup completion for certain functions defined above by setting common
Packit f546b1
# variables and workarounds.
Packit f546b1
# This is NOT a public function; use at your own risk.
Packit f546b1
_gst_inspect_complete ()
Packit f546b1
{
Packit f546b1
	local wrapper="__inspect_wrap${2}"
Packit f546b1
	eval "$wrapper () { _gst_inspect_func_wrap $2 ; }"
Packit f546b1
	complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
Packit f546b1
		|| complete -o default -o nospace -F $wrapper $1
Packit f546b1
}
Packit f546b1
Packit f546b1
_gst_inspect_complete gst-inspect-1.0 __inspect_main