From: Mathieu Duponchelle Date: Thu, 26 Feb 2015 12:19:25 +0000 (+0100) Subject: bash-completion: Add support for new ges-launch commands. X-Git-Tag: 1.19.3~493^2~1244 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e18fd790c8711c0b8829d475d7cf12e7568d446;p=platform%2Fupstream%2Fgstreamer.git bash-completion: Add support for new ges-launch commands. --- diff --git a/data/completions/ges-launch-1.0 b/data/completions/ges-launch-1.0 index f8a126a..e660a8a 100644 --- a/data/completions/ges-launch-1.0 +++ b/data/completions/ges-launch-1.0 @@ -61,6 +61,58 @@ _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 '^ [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___encoding_profile () { _mandatory__argument; } _ges___ges_sample_path () { _mandatory__argument; } @@ -69,9 +121,27 @@ _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 + 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 ]]; do @@ -80,15 +150,18 @@ __ges_main () 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 [ -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 completion_func="_${command//-/_}" else @@ -99,13 +172,19 @@ __ges_main () function_exists=$? - if [[ "$cur" == "--"* ]]; then - COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --help-all | grep -oh '[[:graph:]]*--[[:graph:]]*' | cut -d'=' -f1)" -- $cur) ) + 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 - COMPREPLY=( $(compgen -W "$(ges-launch-1.0 --help-all | grep -oh '[[:graph:]]*--[[:graph:]]*' | cut -d'=' -f1)" -- $cur) ) + _ges_list_commands fi } diff --git a/tools/ges-launch.c b/tools/ges-launch.c index e2f23e5..c1e6a57 100644 --- a/tools/ges-launch.c +++ b/tools/ges-launch.c @@ -637,6 +637,46 @@ _parse_timeline (int argc, char **argv) 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 or ges-launch-1.0 help " + "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 main (int argc, gchar ** argv) { @@ -716,6 +756,7 @@ main (int argc, gchar ** argv) guint signal_watch_id; #endif + _check_command_help (argc, argv); setlocale (LC_ALL, ""); ctx = g_option_context_new ("- plays or renders a timeline.");