From 9f0b93c3ca0ce0c3c69c010cd863b5f9299e0f50 Mon Sep 17 00:00:00 2001 From: Elmir Jagudin Date: Thu, 23 May 2013 11:54:06 +0200 Subject: [PATCH] added bash completions files Added files that can be used to enable tab-completion in bash for 'buildbot' and 'buildslave' commands. --- master/contrib/README.txt | 5 +++ master/contrib/bash/buildbot | 59 +++++++++++++++++++++++++++++++++++ slave/contrib/README.txt | 5 +++ slave/contrib/bash/buildslave | 50 +++++++++++++++++++++++++++++ 4 files changed, 119 insertions(+) create mode 100644 master/contrib/bash/buildbot create mode 100644 slave/contrib/bash/buildslave diff --git a/master/contrib/README.txt b/master/contrib/README.txt index 36a040a42ab..1b8f4ceda3f 100644 --- a/master/contrib/README.txt +++ b/master/contrib/README.txt @@ -47,3 +47,8 @@ css/*.css: alternative HTML stylesheets to make the Waterfall display look zsh/_buildbot: zsh tab-completion file for 'buildbot' command. Put it in one of the directories appearing in $fpath to enable tab-completion in zsh. + +bash/buildslave: bash tab-completion file for 'buildbot' command. Source this + file to enable completions in your bash session. This is + typically accomplished by placing the file into the + appropriate 'bash_completion.d' directory. diff --git a/master/contrib/bash/buildbot b/master/contrib/bash/buildbot new file mode 100644 index 00000000000..c081e62fb5f --- /dev/null +++ b/master/contrib/bash/buildbot @@ -0,0 +1,59 @@ +# +# This file installs BASH completions for 'buildbot' command. +# + +_buildbot() +{ + local buildbot_subcommands=" + create-master upgrade-master start stop restart reconfig sighup user + sendchange debugclient statuslog statusgui try tryserver checkconfig" + + local cur=${COMP_WORDS[COMP_CWORD]} + local subcommand= + local subcommand_args= + local i=1 + + # + # 'parse' the command line so far + # figure out if we have subcommand specified and any arguments to it + # + + # skip global options + while [[ "${COMP_WORDS[$i]}" == -* ]]; + do + i=$(($i+1)) + done + + # save subcommand + subcommand=${COMP_WORDS[$i]} + i=$(($i+1)) + + # skip subcommand options + while [[ "${COMP_WORDS[$i]}" == -* ]]; + do + i=$(($i+1)) + done + + # save subcommand arguments + subcommand_args=${COMP_WORDS[@]:$i:${#COMP_WORDS[@]}} + + if [ "$cur" == "$subcommand" ]; then + # suggest buildbot subcommands + COMPREPLY=( $(compgen -W "$buildbot_subcommands" $cur) ) + elif [ "$cur" == "$subcommand_args" ]; then + # we are at first subcommand argument + case $subcommand in + # these command take base directory as first argument, + # suggest directories + upgrade-master|create-master|start|stop|restart|reconfig|sighup) + COMPREPLY=( $(compgen -A directory $cur) ) + ;; + # checkconfig takes a filename or directory as first argument + checkconfig) + COMPREPLY=( $(compgen -A file $cur) ) + ;; + esac + fi +} + +complete -F _buildbot buildbot diff --git a/slave/contrib/README.txt b/slave/contrib/README.txt index 51594c35963..048f7ad9fe9 100644 --- a/slave/contrib/README.txt +++ b/slave/contrib/README.txt @@ -4,3 +4,8 @@ buildbot: zsh/_buildslave: zsh tab-completion file for 'buildslave' command. Put it in one of the directories appearing in $fpath to enable tab-completion in zsh. + +bash/buildslave: bash tab-completion file for 'buildslave' command. Source this + file to enable completions in your bash session. This is + typically accomplished by placing the file into the + appropriate 'bash_completion.d' directory. diff --git a/slave/contrib/bash/buildslave b/slave/contrib/bash/buildslave new file mode 100644 index 00000000000..04d01a95527 --- /dev/null +++ b/slave/contrib/bash/buildslave @@ -0,0 +1,50 @@ +# +# This file installs BASH completions for 'buildslave' command. +# + +_buildslave() +{ + local buildslave_subcommands=" + create-slave upgrade-slave start stop restart" + + local cur=${COMP_WORDS[COMP_CWORD]} + local subcommand= + local subcommand_args= + local i=1 + + # + # 'parse' the command line so far + # figure out if we have subcommand specified and any arguments to it + # + + # skip global options + while [[ "${COMP_WORDS[$i]}" == -* ]]; + do + i=$(($i+1)) + done + + # save subcommand + subcommand=${COMP_WORDS[$i]} + i=$(($i+1)) + + # skip subcommand options + while [[ "${COMP_WORDS[$i]}" == -* ]]; + do + i=$(($i+1)) + done + + # save subcommand arguments + subcommand_args=${COMP_WORDS[@]:$i:${#COMP_WORDS[@]}} + + if [ "$cur" == "$subcommand" ]; then + # suggest buildbot subcommands + COMPREPLY=( $(compgen -W "$buildslave_subcommands" $cur) ) + elif [ "$cur" == "$subcommand_args" ]; then + # we are at first subcommand argument + # all subcommands can have slave base directory as first argument + # suggest directories + COMPREPLY=( $(compgen -A directory $cur) ) + fi +} + +complete -F _buildslave buildslave