
# m app install <blender-appstore-id>
# m app install <blender-url>
# m app install https://ftp.halifax.rwth-aachen.de/blender/release/Blender5.0/blender-5.0.1-macos-arm64.dmg

# Actually, you could just using brew cask to install.

___x_cmd_mac_app_install(){
    [ $# -gt 0 ]    ||      set -- --auto

    local method="name"
    while [ $# -gt 0 ]; do
        case "$1" in
            -f|--file)      method=file;     shift ;;
            -n|--name)      method=name;     shift ;;
            --url)          method=url ;     shift ;;

            --auto|--app)   method="${1#--}" shift ;;
            -h|--help)      ___x_cmd help -m app install ; return 0 ;;
            *)              break ;;
        esac
    done

    # local res="$1"
    # [ -z "$method" ] || {
    #     case "$res" in
    #         https*://*|ftps://*)         method=url     ;;
    #         *.dmg|*.pkg|*.DMG|*.PKG)     method=file    ;;
    #         *)                           method=name    ;;
    #     esac
    # }

    ___x_cmd_mac_app_install___"$method" "$@"

}

___x_cmd_mac_app_install___url(){
    mac:error "This feature is currently unavailable."
    return 1
}

___x_cmd_mac_app_install___name(){
    ___x_cmd brew install "$@"
}

___x_cmd_mac_app_install___file(){
    mac:error "This feature is currently unavailable."
    return 1
}

___x_cmd_mac_app_install___appid(){
    ___x_cmd mac as install "$@"
}

___x_cmd_mac_app_install___app(){
    # ___x_cmd mac as
    ___x_cmd brew la --casks --app
}

___x_cmd_mac_app_install___auto(){
    if      ___x_cmd_is_stdout2tty; then        ___x_cmd_mac_app_install___app
    else                                        ___x_cmd help -m app install
    fi
}
