"Fossies" - the Fresh Open Source Software Archive

Member "gstreamer-1.16.1/data/bash-completion/completions/gst-inspect-1.0" (19 Apr 2019, 2599 Bytes) of package /linux/misc/gstreamer-1.16.1.tar.xz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # GStreamer
    2 # Copyright (C) 2015 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
    3 #
    4 # bash/zsh completion support for gst-inspect
    5 #
    6 # This library is free software; you can redistribute it and/or
    7 # modify it under the terms of the GNU Library General Public
    8 # License as published by the Free Software Foundation; either
    9 # version 2 of the License, or (at your option) any later version.
   10 #
   11 # This library is distributed in the hope that it will be useful,
   12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14 # Library General Public License for more details.
   15 #
   16 # You should have received a copy of the GNU Library General Public
   17 # License along with this library; if not, write to the
   18 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
   19 # Boston, MA 02110-1301, USA.
   20 
   21 _GST_HELPERDIR="${BASH_SOURCE[0]%/*}/../helpers"
   22 
   23 if [[ ! -d "$_GST_HELPERDIR"  ]]; then
   24 	_GST_HELPERDIR="$(pkg-config --variable=bashhelpersdir gstreamer-1.0)"
   25 else
   26 	_GST_HELPERDIR=`cd "$_GST_HELPERDIR"; pwd`
   27 fi
   28 
   29 # Common definitions
   30 . "$_GST_HELPERDIR"/gst
   31 
   32 _gst_inspect_all_arguments ()
   33 {
   34 	_gst_all_arguments gst-inspect-1.0
   35 }
   36 
   37 _gst_inspect_all_elements ()
   38 {
   39 	COMPREPLY=( $(compgen -W "$($_GST_HELPER -l)" -- $cur) )
   40 }
   41 
   42 _gstinspect___atleast_version () { _gst_mandatory_argument gst-inspect-1.0; }
   43 
   44 _gstinspect___exists ()
   45 {
   46 	_gst_inspect_all_elements
   47 }
   48 
   49 __inspect_main ()
   50 {
   51 	local i=1 command function_exists completion_func
   52 
   53 	while [[ $i -ne $COMP_CWORD ]];
   54 		do
   55 			local var
   56 			var="${COMP_WORDS[i]}"
   57 			if [[ "$var" == "-"* ]]
   58 			then
   59 				command="$var"
   60 			fi
   61 		i=$(($i+1))
   62 		done
   63 
   64 	if [[ "$command" == "--gst"* ]]; then
   65 		completion_func="_${command//-/_}"
   66 	else
   67 		completion_func="_gstinspect_${command//-/_}"
   68 	fi
   69 
   70 	declare -f $completion_func >/dev/null 2>&1
   71 
   72 	function_exists=$?
   73 
   74 	if [[ "$cur" == "-"* ]]
   75         then
   76 		_gst_inspect_all_arguments
   77 	elif [ $function_exists -eq 0 ]
   78 	then
   79 		$completion_func
   80 	else
   81 		_gst_inspect_all_elements
   82 	fi
   83 }
   84 
   85 _gst_inspect_func_wrap ()
   86 {
   87 	local cur prev
   88 	cur="${COMP_WORDS[COMP_CWORD]}"
   89 	prev="${COMP_WORDS[COMP_CWORD-1]}"
   90 	$1
   91 }
   92 
   93 # Setup completion for certain functions defined above by setting common
   94 # variables and workarounds.
   95 # This is NOT a public function; use at your own risk.
   96 _gst_inspect_complete ()
   97 {
   98 	local wrapper="__inspect_wrap${2}"
   99 	eval "$wrapper () { _gst_inspect_func_wrap $2 ; }"
  100 	complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
  101 		|| complete -o default -o nospace -F $wrapper $1
  102 }
  103 
  104 _gst_inspect_complete gst-inspect-1.0 __inspect_main