_ordinaryd() {
    local i cur prev opts cmd
    COMPREPLY=()
    if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then
        cur="$2"
    else
        cur="${COMP_WORDS[COMP_CWORD]}"
    fi
    prev="$3"
    cmd=""
    opts=""

    for i in "${COMP_WORDS[@]:0:COMP_CWORD}"
    do
        case "${cmd},${i}" in
            ",$1")
                cmd="ordinaryd"
                ;;
            ordinaryd,api)
                cmd="ordinaryd__api"
                ;;
            ordinaryd,app)
                cmd="ordinaryd__app"
                ;;
            ordinaryd,help)
                cmd="ordinaryd__help"
                ;;
            ordinaryd,init)
                cmd="ordinaryd__init"
                ;;
            ordinaryd__help,api)
                cmd="ordinaryd__help__api"
                ;;
            ordinaryd__help,app)
                cmd="ordinaryd__help__app"
                ;;
            ordinaryd__help,help)
                cmd="ordinaryd__help__help"
                ;;
            ordinaryd__help,init)
                cmd="ordinaryd__help__init"
                ;;
            *)
                ;;
        esac
    done

    case "${cmd}" in
        ordinaryd)
            opts="-h -V --data-dir --stdio-logs --stdio-pretty --stdio-json --json-logs --log-level --with-span-timing --log-file-rotation --log-size --help --version init api app help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --data-dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-level)
                    COMPREPLY=($(compgen -W "error warn info debug trace" -- "${cur}"))
                    return 0
                    ;;
                --log-file-rotation)
                    COMPREPLY=($(compgen -W "day hour minute never" -- "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__api)
            opts="-h -V --environment --storage-size --provision --port --redirect-port --insecure --insecure-cookies --log-headers --log-ips --redacted-header-hash --dedicated-ports --log-index --log-sync-interval-min --log-sync-interval-max --log-max-ttl-days --swagger --data-dir --stdio-logs --stdio-pretty --stdio-json --json-logs --log-level --with-span-timing --log-file-rotation --log-size --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --environment)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --storage-size)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --provision)
                    COMPREPLY=($(compgen -W "staging production localhost" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --redirect-port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --redacted-header-hash)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-sync-interval-min)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-sync-interval-max)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-max-ttl-days)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --data-dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-level)
                    COMPREPLY=($(compgen -W "error warn info debug trace" -- "${cur}"))
                    return 0
                    ;;
                --log-file-rotation)
                    COMPREPLY=($(compgen -W "day hour minute never" -- "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__app)
            opts="-h -V --provision --port --redirect-port --insecure --insecure-cookies --log-headers --log-ips --redacted-header-hash --project-dir --domain-override --data-dir --stdio-logs --stdio-pretty --stdio-json --json-logs --log-level --with-span-timing --log-file-rotation --log-size --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --provision)
                    COMPREPLY=($(compgen -W "staging production localhost" -- "${cur}"))
                    return 0
                    ;;
                --port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --redirect-port)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --redacted-header-hash)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --project-dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --domain-override)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --data-dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-level)
                    COMPREPLY=($(compgen -W "error warn info debug trace" -- "${cur}"))
                    return 0
                    ;;
                --log-file-rotation)
                    COMPREPLY=($(compgen -W "day hour minute never" -- "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__help)
            opts="init api app help"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__help__api)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__help__app)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__help__help)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__help__init)
            opts=""
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
        ordinaryd__init)
            opts="-h -V --environment --storage-size --api-domain --password --mfa-stored --api-contacts --app-domains --privileged-domains --data-dir --stdio-logs --stdio-pretty --stdio-json --json-logs --log-level --with-span-timing --log-file-rotation --log-size --help --version"
            if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then
                COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
                return 0
            fi
            case "${prev}" in
                --environment)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --storage-size)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --api-domain)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --password)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --api-contacts)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --app-domains)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --privileged-domains)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --data-dir)
                    COMPREPLY=($(compgen -f "${cur}"))
                    return 0
                    ;;
                --log-level)
                    COMPREPLY=($(compgen -W "error warn info debug trace" -- "${cur}"))
                    return 0
                    ;;
                --log-file-rotation)
                    COMPREPLY=($(compgen -W "day hour minute never" -- "${cur}"))
                    return 0
                    ;;
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
    esac
}

if [[ "${BASH_VERSINFO[0]}" -eq 4 && "${BASH_VERSINFO[1]}" -ge 4 || "${BASH_VERSINFO[0]}" -gt 4 ]]; then
    complete -F _ordinaryd -o nosort -o bashdefault -o default ordinaryd
else
    complete -F _ordinaryd -o bashdefault -o default ordinaryd
fi
