# shellcheck shell=dash

# ___x_cmd___run_with_engine
___x_cmd_solo_engine_runmain(){
    local engine="${1:?Please provide engine}";
    local filepath="${2:?Please provide filepath}";        shift 2
    case "$engine" in
        xrc)            ___x_cmd_solo_engine___run_xrc       "$filepath" "$@"    ;;
        source)         ___x_cmd_solo_engine___run_source    "$filepath" "$@"    ;;
        xsh)        (   ___x_cmd_solo_engine___run_source    "$filepath" "$@"; ) ;;
        7z)             ___x_cmd_main 7z x              "$filepath" "$@"    ;;
        txt)            ___x_cmd_cmds_cat               "$filepath" ;;

        awk|cawk)   ___x_cmd cawk                       "$filepath" ;;
        mawk)       ___x_cmd mawk                       "$filepath" ;;
        gawk)       ___x_cmd gawk                       "$filepath" ;;

        python)     ___x_cmd python                     "$filepath" "$@" ;;
        hylang)     ___x_cmd hy                         "$filepath" "$@" ;;
        julia)      ___x_cmd julia                      "$filepath" "$@" ;;
        rl)         ___x_cmd rl                         "$filepath" "$@" ;;     # rlang

        lisp)       ___x_cmd sbcl                       "$filepath" "$@" ;;
        elisp)      ___x_cmd elisp                      "$filepath" "$@" ;;

        perl)       ___x_cmd perl                       "$filepath" "$@" ;;
        raku)       ___x_cmd raku                       "$filepath" "$@" ;;
        ruby)       ___x_cmd ruby                       "$filepath" "$@" ;;

        node)       ___x_cmd node                       "$filepath" "$@" ;;
        ts)         ___x_cmd tsnode                     "$filepath" "$@" ;;
        deno)       ___x_cmd deno                       "$filepath" "$@" ;;

        java)       ___x_cmd java                       "$filepath" "$@" ;;
        jar)        ___x_cmd jar                        "$filepath" "$@" ;;
        groovy|gvy) ___x_cmd groovy                     "$filepath" "$@" ;;
        clojure)    ___x_cmd clojure                    "$filepath" "$@" ;;
        scala)      ___x_cmd scala                      "$filepath" "$@" ;;
        kotlin)     ___x_cmd kotlin                     "$filepath" "$@" ;;

        go|gop|xgo|zig)
                    ___x_cmd "$engine"                  "$filepath" "$@" ;;

        lua)        ___x_cmd "$engine" --xrun           "$filepath" "$@" ;;

        fish)       ___x_cmd fish                       "$filepath" "$@" ;;

        doc|docs|xls|xlsx|ppt|pptx|pdf)
                    ___x_cmd open                       "$filepath" ;;

        jxa)        ___x_cmd jxa run                    "$filepath" "$@" ;;
        ps)         ___x_cmd pwsh run                   "$filepath" "$@" ;;

        action)     ___x_cmd action apply               "$filepath" ;;
        script)     ___x_cmd script apply               "$filepath" ;;

        speg)       ___x_cmd script play                "$filepath" ;;

        wx)         ___x_cmd wx run                     "$filepath" "$@" ;;

        # TODO: download vlc to play.
        mp3|mp4)
                    ___x_cmd open "$filepath" ;;

        *)          ___x_cmd_main "$engine" "$filepath" "$@" ;;
    esac
}

