Blame data/bash-completion/helpers/gst.in

Packit a6ee4b
# GStreamer
Packit a6ee4b
# Copyright (C) 2015 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
Packit a6ee4b
#
Packit a6ee4b
# bash/zsh completion support for common gstreamer options
Packit a6ee4b
#
Packit a6ee4b
# This library is free software; you can redistribute it and/or
Packit a6ee4b
# modify it under the terms of the GNU Library General Public
Packit a6ee4b
# License as published by the Free Software Foundation; either
Packit a6ee4b
# version 2 of the License, or (at your option) any later version.
Packit a6ee4b
#
Packit a6ee4b
# This library is distributed in the hope that it will be useful,
Packit a6ee4b
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit a6ee4b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit a6ee4b
# Library General Public License for more details.
Packit a6ee4b
#
Packit a6ee4b
# You should have received a copy of the GNU Library General Public
Packit a6ee4b
# License along with this library; if not, write to the
Packit a6ee4b
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
Packit a6ee4b
# Boston, MA 02110-1301, USA.
Packit a6ee4b
Packit a6ee4b
_GST_HELPER="@GST_COMPLETION_HELPER_INSTALLED@"
Packit a6ee4b
if [[ ! -x "$_GST_HELPER" ]]
Packit a6ee4b
then
Packit a6ee4b
        helper="$(pkg-config --variable=helpersdir gstreamer-@GST_API_VERSION@)/gst-completion-helper"
Packit a6ee4b
Packit a6ee4b
        if [ -x "$helper" ]
Packit a6ee4b
        then
Packit a6ee4b
          _GST_HELPER=$helper
Packit a6ee4b
        fi
Packit a6ee4b
fi
Packit a6ee4b
Packit a6ee4b
___gst_debug_level () { _gst_mandatory_argument; }
Packit a6ee4b
___gst_debug () { _gst_mandatory_argument; }
Packit a6ee4b
___gst_debug_color_mode () { _gst_mandatory_argument; }
Packit a6ee4b
___gst_plugin_path () { _gst_mandatory_argument; }
Packit a6ee4b
___gst_plugin_load () { _gst_mandatory_argument; }
Packit a6ee4b
Packit a6ee4b
_gst_all_arguments ()
Packit a6ee4b
{
Packit a6ee4b
	COMPREPLY=( $(compgen -W "$($1 --help-all | grep "^  -" | grep -oh '[[:graph:]]*--[[:graph:]]*\|-[[:alpha:]],' | cut -d'=' -f1 | cut -d',' -f1)" -- $cur) )
Packit a6ee4b
}
Packit a6ee4b
Packit a6ee4b
_gst_mandatory_argument ()
Packit a6ee4b
{
Packit a6ee4b
	__app=$1
Packit a6ee4b
	if [[ -z $__app ]]
Packit a6ee4b
	then
Packit a6ee4b
		__app=gst-launch-1.0
Packit a6ee4b
	fi
Packit a6ee4b
Packit a6ee4b
	if [[ "$prev" != "$command" ]]
Packit a6ee4b
	then
Packit a6ee4b
		_gst_all_arguments $__app
Packit a6ee4b
	else
Packit a6ee4b
		COMPREPLY=("$cur")
Packit a6ee4b
	fi
Packit a6ee4b
}