#!bin/bash

_sgdfe_completion() {
    local current options
    COMPREPLY=()
    current="${COMP_WORDS[COMP_CWORD]}"
    options="--daemon --help -h --version -v"

    if [ ${COMP_CWORD} -eq 1 ] ; then
        COMPREPLY=($(compgen -W "${options}" -- ${current}))
        return
    fi
 }
complete -F _sgdfe_completion sgdfe

_sgdfe-conf_completion() {
    local current previous options
    COMPREPLY=()
    current="${COMP_WORDS[COMP_CWORD]}"
    previous="${COMP_WORDS[COMP_CWORD-1]}"
    options="configure import update list"

    if [ ${COMP_CWORD} -eq 1 ] ; then
        COMPREPLY=($(compgen -W "${options}" -- ${current}))
        return
    fi

    case "${previous}" in
        configure)
            COMPREPLY=($(compgen -W "backup database proxy sgdfe-server" -- ${current}))
        ;;

        list)
            COMPREPLY=($(compgen -W "api-login api-url backup contingencia database proxy sgdfe-server uf web-server" -- ${current}))
        ;;
    esac
 }
complete -F _sgdfe-conf_completion sgdfe-conf
