# bash completion for git-edit-date

_git_edit_date() {
    local cur prev
    COMPREPLY=()
    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    if [[ ${COMP_CWORD} -eq 1 ]]; then
        COMPREPLY=( $(compgen -W "export apply completion help" -- "${cur}") )
        return 0
    fi

    case "${COMP_WORDS[1]}" in
        export)
            case "${prev}" in
                -o|-repo)
                    COMPREPLY=( $(compgen -f -- "${cur}") )
                    ;;
                *)
                    COMPREPLY=( $(compgen -W "-o -repo" -- "${cur}") )
                    ;;
            esac
            ;;
        apply)
            case "${prev}" in
                -file|-repo)
                    COMPREPLY=( $(compgen -f -- "${cur}") )
                    ;;
                *)
                    COMPREPLY=( $(compgen -W "-file -repo -allow-dirty" -- "${cur}") )
                    ;;
            esac
            ;;
        completion)
            if [[ ${COMP_CWORD} -eq 2 ]]; then
                COMPREPLY=( $(compgen -W "bash zsh" -- "${cur}") )
            fi
            ;;
    esac
}

complete -F _git_edit_date git-edit-date
