summaryrefslogtreecommitdiff
path: root/data/completions/ges-launch-1.0
blob: 14b36557ecc0354ca9d8bb1fb0eb10c2fd8f5b0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# GStreamer
# Copyright (C) 2015 Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
#
# bash/zsh completion support for ges-launch
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.

HELPERDIR="${BASH_SOURCE[0]%/*}/../helpers"

if [[ ! -d "$HELPERDIR" ]]; then
	HELPERDIR="$(pkg-config --variable=helpersdir gstreamer-1.0)"
else
	HELPERDIR=`cd "$HELPERDIR"; pwd`
fi

# Common definitions
. "$HELPERDIR"/gst

HELPER="$HELPERDIR/gst-completion-helper-1.0"

_ges___inspect_action_type ()
{
	COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --inspect-action-type | grep '^[^ ]' | cut -d':' -f2)" -- $cur) )
}

_ges___track_types ()
{
	COMPREPLY=( $(compgen -W "audio video audio+video" -- $cur) )
}

_ges___set_scenario () {
	COMPREPLY=( $(compgen -W "*.scenario $(gst-validate-1.0 -l | awk '$0=$2' FS=[ RS=])" -- $cur) )
}

_ges___load () {
	COMPREPLY=( $(compgen -W "*.xges" -- $cur) )
}

_ges___outputuri () {
	COMPREPLY=( $(compgen -W "file://" -- $cur) )
}

_ges___audiosink () {
	COMPREPLY=( $(compgen -W "$($HELPER --klass=Sink --sinkcaps='audio/x-raw')" -- $cur) )
}

_ges___videosink () {
	COMPREPLY=( $(compgen -W "$($HELPER --klass=Sink --sinkcaps='video/x-raw')" -- $cur) )
}

_ges_clip () {
	if [[ "$prev" == "$command" ]];
	then
		_mandatory__argument
	else
		COMPREPLY=( $(compgen -W "duration= inpoint= start= layer= $(ges-launch-1.0 help all | egrep '^  [a-zA-Z0-9]')" -- $cur) )
	fi
}

_ges_effect () {
	if [[ "$prev" == "$command" ]];
	then
		_mandatory__argument
	else
		COMPREPLY=( $(compgen -W "duration= start= layer= $(ges-launch-1.0 help all | egrep '^  +')" -- $cur) )
	fi
}

_ges_list_options () {
	COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --help-all | grep -oh '[[:graph:]]*--[[:graph:]]*' | cut -d'=' -f1)" -- $cur) )
}

_ges_list_commands () {
	COMPREPLY=( $(compgen -W "$(ges-launch-1.0 help all | egrep '^  +')" -- $cur) )
}

_ges_list_properties () {
	local props

	if [[ "$real_command" == "" ]]
	then
		_mandatory__argument
	elif [[ "$real_command" == "+clip" ]]
	then
		COMPREPLY=( $(compgen -W "set-alpha set-posx set-posy set-width set-height set-volume set-mute" -- $cur) )
	elif [[ "$real_command" == "+effect" ]]
	then
		COMPREPLY=()
		effect_bin_description="${effect_bin_description//\"/ }"
		array=(${effect_bin_description//!/ })
		for i in "${array[@]}"; do
			props=("$($HELPER --element-properties $i)")
			for j in $props; do
				j="${j//=/ }"
				COMPREPLY+=( $(compgen -W "set-$j" -- $cur) )
			done
		done
	else
		_mandatory__argument
	fi
}

_ges___exclude_ () { _mandatory__argument; }
_ges___encoding_profile () { _mandatory__argument; }
_ges___ges_sample_path () { _mandatory__argument; }
_ges___ges_sample_path_recurse () { _mandatory__argument; }
_ges___thumbnail () { _mandatory__argument; }
_ges___repeat () { _mandatory__argument; }
_ges___save () { _mandatory__argument; }

containsElement () {
	local e
	for e in "${@:2}";
	do
		[[ "$e" == "$1" ]] && return 0;
	done
	return 1
}

__ges_main ()
{
	local i=1 c=1 command function_exists completion_func commands real_command effect_bin_description

	commands=($(ges-launch-1.0 help all | egrep '^  +'))
	real_command=""
	effect_bin_description=""

	if [[ "$cur" == "=" ]]; then
		_mandatory__argument
		return
	fi

	while [[ $i -ne $COMP_CWORD ]];
		do
			local var
			var="${COMP_WORDS[i]}"
			if [[ "$var" == "--"* ]]
			then
				command="$var"
			elif containsElement "$var" "${commands[@]}";
			then
				real_command="$var"
				command="$var"
				if [[ "$var" == "+effect" ]]
				then
					effect_bin_description="${COMP_WORDS[i+1]}"
				fi
			fi
		i=$[$i+1]
		done

	if [[ "$command" == "--gst"* ]]; then
		completion_func="_${command//-/_}"
	else
		completion_func="_ges_${command//-|+/_}"
		completion_func="${completion_func//+/}"
	fi

	declare -f $completion_func >/dev/null 2>&1

	function_exists=$?

	if [[ "$cur" == "-"* ]]; then
		_ges_list_options
	elif [[ "$cur" == "="* ]]
	then
		_mandatory__argument
	elif [[ "$cur" == "set-"* ]]
	then
		_ges_list_properties
	elif [ $function_exists -eq 0 ]
	then
		$completion_func
	else
		_ges_list_commands
	fi
}

__ges_func_wrap ()
{
	local cur prev
	cur="${COMP_WORDS[COMP_CWORD]}"
	prev="${COMP_WORDS[COMP_CWORD-1]}"
	$1
}

# Setup completion for certain functions defined above by setting common
# variables and workarounds.
# This is NOT a public function; use at your own risk.
__ges_complete ()
{
	local wrapper="__ges_wrap${2}"
	eval "$wrapper () { __ges_func_wrap $2 ; }"
	complete -o bashdefault -o default -o nospace -F $wrapper $1 2>/dev/null \
		|| complete -o default -o nospace -F $wrapper $1
}

_ges ()
{
	__ges_wrap__ges_main
}

__ges_complete ges-launch-1.0 __ges_main