# shellcheck shell=dash

___x_cmd_deno___enginerun_hub_run(){
    local ___X_CMD_DENO_WHICHFILE=""
    local x_=""
    ___x_cmd_deno___setarg_ "$@" || return
    deno:debug "Args ==> $*"
    deno:debug "cmd x_ ==> $x_"

    # [ -z "$x_" ] || eval "$x_"
    # ___x_cmd_deno___cmd deno "$@"
    deno:debug "cmdstr -> deno $cmdstr_prefix run $x_"
    # eval echo ___x_cmd_deno___cmd deno "$cmdstr_prefix" run "$x_"
    eval ___x_cmd_deno___cmd deno "$cmdstr_prefix" run "$x_"
}

___x_cmd_deno___enginerun(){
    (
        local cmdstr_prefix=

        while [ $# -gt 0 ]; do
            case "$1" in
                -*)
                    cmdstr_prefix="$cmdstr_prefix $1";
                    shift
                    ;;
                bench|bundle|cache|check|compile|completions|coverage|doc|eval|fmt|\
                help|info|init|install|jupyter|lint|lsp|repl|task|test|types|\
                uninstall|upgrade|vendor)
                    # Or we just directly run the command ...
                    eval  ___x_cmd_deno___cmd deno "$cmdstr_prefix" '"$@"'
                    return
                    ;;
                run)
                    shift
                    ___x_cmd_deno___enginerun_hub_run   "$@"
                    return
                    ;;
                *)
                    ___x_cmd_deno___enginerun_hub_run   "$@"
                    return
                    ;;

                    # local ___X_CMD_DENO_WHICHFILE=""
                    # if ___x_cmd_deno___which_one "$1"; then
                    #     ___x_cmd_deno___enginerun_hub run "$@"
                    # else
                    #     deno:debug "Considered as code ==> $*"
                    #     local IFS=" "
                    #     ___x_cmd_deno___cmd deno eval "$*"
                    # fi
            esac
        done
    )
}
