# chkconfig(8) completion


comp_include _get_cword _services


_chkconfig()
{
    local cur prev

    COMPREPLY=()
    cur=`_get_cword`
    prev=${COMP_WORDS[COMP_CWORD-1]}

    case "$prev" in
    @([1-6]|--@(list|add|del)))
        _services
        return 0
        ;;
    --level)
        COMPREPLY=( $( compgen -W '1 2 3 4 5 6' -- $cur ) )
        return 0
        ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $( compgen -W '--list --add --del --level' -- $cur ) )
    else
        if [ $COMP_CWORD -eq 2 -o $COMP_CWORD -eq 4 ]; then
            COMPREPLY=( $( compgen -W 'on off reset' -- $cur ) )
        else
            _services
        fi
    fi
} # chkconfig()
