# Debian apt-manage completion    

_apt_manage()
{
    local cur prev words cword package
    _init_completion -n ':=' || return

    local special i
    i=0
    for (( i=0; i < ${#words[@]}-1; i++ )); do
        if [[ ${words[i]} == @(add|list|modify|remove|key) ]]; then
            special=${words[i]}
        fi
    done

    if [[ -n $special ]]; then
        case $special in
            list|modify|remove|key)
                COMPREPLY=( $( compgen -W '$(apt-manage list -n)' -- "$cur" ) )
                return
                ;;
            *)
                ;;
        esac
    fi


    if [[ "$cur" == -* ]]; then
        return
    #     COMPREPLY=( $(compgen -W '
    #         --help --disable --source-code --expand
    #         --verbose --legacy --no-names
    #         --enable --disable --name --add-suite --remove-suite
    #           --add-component --remove-component --add-uri --remove-uri
    #         ' -- "$cur") )
    else
        COMPREPLY=( $(compgen -W 'add list modify remove key' \
            -- "$cur") )
    fi

} &&
complete -F _apt_manage apt-manage
