autoload bashcompinit
bashcompinit

#thx to https://www.endpoint.com/blog/2016/06/03/adding-bash-completion-to-python-script


_show_complete()
{
    local cur prev opts node_names
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"
    opts=`book-time -options`
    if [[ ${prev} != -* || ${cur} == -* ]] ; then
        COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
        return 0
    fi
    if [[ ${prev} == -* ]] ; then
        lookup_arg=$(echo "$prev" | sed 's/^-*\(.*\)/\1/')
        opts_arg=`book-time -options ${lookup_arg}`
        COMPREPLY=( $(compgen -W "${opts_arg}") )
        return 0
    fi
}

complete -F _show_complete book-time
