_Sherpa()
{
    local cur prev opts ret
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts="$(cat @DATADIR@/options.index)"

    if [[ ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi
    if [[ ${cur} == *=* ]] ; then
       COMPREPLY=()
       return 0
    fi

    ret="$(compgen -W "$(cat @DATADIR@/completion.index)" -- ${cur})"
    if [[ ${ret} == "" ]] ; then
      COMPREPLY=()
      return 0
    else
      COMPREPLY=(${ret}=)
      return 0
    fi
}
complete -o nospace -o default -F _Sherpa Sherpa@VERSIONING@
