1# vim: syntax=sh
2_ubic()
3{
4    local cur prev
5    COMPREPLY=()
6    cur=${COMP_WORDS[COMP_CWORD]}
7
8    commands='start stop restart try-restart reload force-reload status'
9
10    if [[ $COMP_CWORD -eq 1 ]] ; then
11        COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
12        return 0
13    fi
14
15    prev=${COMP_WORDS[COMP_CWORD-1]}
16
17    if [[ $COMP_CWORD -eq 2 ]] ; then
18        if [[ "x$prev" == "xlist" ]] ; then
19            return 0
20        fi
21        COMPREPLY=( $(cur=$cur perl -MUbic -le 'print join "\n", Ubic->compl_services($ENV{cur})') )
22    fi
23
24    return 0
25}
26
27complete -F _ubic -o nospace ubic
28