# shellcheck shell=dash disable=SC2034

___x_cmd_upgrade___main(){
    local X_help_cmd="x help -m x-cmd upgrade"; help:arg:parse

    local version="${1:-"${___X_CMD_VERSION0:-$___X_CMD_VERSION}"}"
    local update_url="https://get.x-cmd.com"
    case "$version" in
        latest|beta|alpha|x[0-9])
                update_url="${update_url}/${version}"
                ;;
        v*)
                local ___X_CMD_TOINSTALL_VERSION="$version" ;;
        *)      M="Version[$version] error, unable to upgrade" N=x log:ret:64 ;;
    esac

    x:info --url "$update_url" "Upgrading x-cmd version => $version"

    if ___x_cmd_is_interactive_tty; then
        eval "$( ___x_cmd curl "$update_url" )"
    else
        eval "$( ___x_cmd curl "$update_url" )" <<A
A
    fi

}
