Skip to content

Commit

Permalink
added bash completions files
Browse files Browse the repository at this point in the history
Added files that can be used to enable tab-completion in bash
for 'buildbot' and 'buildslave' commands.
  • Loading branch information
Elmir Jagudin committed Jun 3, 2013
1 parent c9cbd58 commit 9f0b93c
Show file tree
Hide file tree
Showing 4 changed files with 119 additions and 0 deletions.
5 changes: 5 additions & 0 deletions master/contrib/README.txt
Expand Up @@ -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.
59 changes: 59 additions & 0 deletions 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
5 changes: 5 additions & 0 deletions slave/contrib/README.txt
Expand Up @@ -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.
50 changes: 50 additions & 0 deletions 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

0 comments on commit 9f0b93c

Please sign in to comment.