mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
bash-completion: Add support for new ges-launch commands.
This commit is contained in:
parent
d77ad923a6
commit
8e18fd790c
2 changed files with 129 additions and 9 deletions
|
@ -61,6 +61,58 @@ _ges___videosink () {
|
||||||
COMPREPLY=( $(compgen -W "$($HELPER --klass=Sink --sinkcaps='video/x-raw')" -- $cur) )
|
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 '^ [a-zA-Z0-9]')" -- $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 '^ [a-zA-Z0-9]')" -- $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___exclude_ () { _mandatory__argument; }
|
||||||
_ges___encoding_profile () { _mandatory__argument; }
|
_ges___encoding_profile () { _mandatory__argument; }
|
||||||
_ges___ges_sample_path () { _mandatory__argument; }
|
_ges___ges_sample_path () { _mandatory__argument; }
|
||||||
|
@ -69,9 +121,27 @@ _ges___thumbnail () { _mandatory__argument; }
|
||||||
_ges___repeat () { _mandatory__argument; }
|
_ges___repeat () { _mandatory__argument; }
|
||||||
_ges___save () { _mandatory__argument; }
|
_ges___save () { _mandatory__argument; }
|
||||||
|
|
||||||
|
containsElement () {
|
||||||
|
local e
|
||||||
|
for e in "${@:2}";
|
||||||
|
do
|
||||||
|
[[ "$e" == "$1" ]] && return 0;
|
||||||
|
done
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
__ges_main ()
|
__ges_main ()
|
||||||
{
|
{
|
||||||
local i=1 c=1 command function_exists completion_func
|
local i=1 c=1 command function_exists completion_func commands real_command effect_bin_description
|
||||||
|
|
||||||
|
commands=($(ges-launch-1.0 help all | egrep '^ [a-zA-Z0-9]'))
|
||||||
|
real_command=""
|
||||||
|
effect_bin_description=""
|
||||||
|
|
||||||
|
if [[ "$cur" == "=" ]]; then
|
||||||
|
_mandatory__argument
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
while [[ $i -ne $COMP_CWORD ]];
|
while [[ $i -ne $COMP_CWORD ]];
|
||||||
do
|
do
|
||||||
|
@ -80,15 +150,18 @@ __ges_main ()
|
||||||
if [[ "$var" == "--"* ]]
|
if [[ "$var" == "--"* ]]
|
||||||
then
|
then
|
||||||
command="$var"
|
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
|
fi
|
||||||
i=$[$i+1]
|
i=$[$i+1]
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$command" ]; then
|
|
||||||
COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --help-all | grep -oh '[[:graph:]]*--[[:graph:]]*' | cut -d'=' -f1)" -- $cur) )
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$command" == "--gst"* ]]; then
|
if [[ "$command" == "--gst"* ]]; then
|
||||||
completion_func="_${command//-/_}"
|
completion_func="_${command//-/_}"
|
||||||
else
|
else
|
||||||
|
@ -99,13 +172,19 @@ __ges_main ()
|
||||||
|
|
||||||
function_exists=$?
|
function_exists=$?
|
||||||
|
|
||||||
if [[ "$cur" == "--"* ]]; then
|
if [[ "$cur" == "-"* ]]; then
|
||||||
COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --help-all | grep -oh '[[:graph:]]*--[[:graph:]]*' | cut -d'=' -f1)" -- $cur) )
|
_ges_list_options
|
||||||
|
elif [[ "$cur" == "="* ]]
|
||||||
|
then
|
||||||
|
_mandatory__argument
|
||||||
|
elif [[ "$cur" == "set-"* ]]
|
||||||
|
then
|
||||||
|
_ges_list_properties
|
||||||
elif [ $function_exists -eq 0 ]
|
elif [ $function_exists -eq 0 ]
|
||||||
then
|
then
|
||||||
$completion_func
|
$completion_func
|
||||||
else
|
else
|
||||||
COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --help-all | grep -oh '[[:graph:]]*--[[:graph:]]*' | cut -d'=' -f1)" -- $cur) )
|
_ges_list_commands
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -637,6 +637,46 @@ _parse_timeline (int argc, char **argv)
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_print_all_commands (void)
|
||||||
|
{
|
||||||
|
/* Yeah I know very fancy */
|
||||||
|
g_print ("Available ges-launch-1.0 commands:\n\n");
|
||||||
|
g_print (" %-9s %-11s %-10s\n\n", "+clip", "+effect", "set-");
|
||||||
|
g_print ("See ges-launch-1.0 help <command> or ges-launch-1.0 help <guide> "
|
||||||
|
"to read about a specific command or a given guide\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_check_command_help (int argc, gchar ** argv)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* gchar *page = NULL;
|
||||||
|
*
|
||||||
|
* if (argc == 2)
|
||||||
|
* page = g_strdup ("ges-launch-1.0");
|
||||||
|
* else if (!g_strcmp0 (argv[2], "all"))
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!g_strcmp0 (argv[1], "help")) {
|
||||||
|
_print_all_commands ();
|
||||||
|
exit (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* else
|
||||||
|
* page = g_strconcat ("ges-launch-1.0", "-", argv[2], NULL);
|
||||||
|
*
|
||||||
|
* if (page) {
|
||||||
|
* execlp ("man", "man", page, NULL);
|
||||||
|
* g_free (page);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* an error is raised by execlp it will be displayed in the terminal
|
||||||
|
* exit (0);
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, gchar ** argv)
|
main (int argc, gchar ** argv)
|
||||||
{
|
{
|
||||||
|
@ -716,6 +756,7 @@ main (int argc, gchar ** argv)
|
||||||
guint signal_watch_id;
|
guint signal_watch_id;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_check_command_help (argc, argv);
|
||||||
setlocale (LC_ALL, "");
|
setlocale (LC_ALL, "");
|
||||||
|
|
||||||
ctx = g_option_context_new ("- plays or renders a timeline.");
|
ctx = g_option_context_new ("- plays or renders a timeline.");
|
||||||
|
|
Loading…
Reference in a new issue