R/version.R

Defines functions is_latest_version version

Documented in is_latest_version version

#' Fetch information about the local and remote
#' Cloudstan versions.
#'
#' @return Object containing version information.
#'
#' @export
#'
version <- function() {
  rsp <- processx::run(
    bin_path(),
    args = c(
      "--json",
      "--non-interactive",
      "version",
      "--remote"
    ),
    spinner = TRUE,
    error_on_status = FALSE
  )
  jsonlite::parse_json(rsp$stdout)$success
}

#' Reports whether the currently installed CLI
#' is the latest version.
#'
#' @return Boolean indicating if CLI version is latest.
#'
#' @export
#'
is_latest_version <- function() {
  if(bin_exists()) {
    version <- version()
    version$version == version$remoteVersion
  } else {
    FALSE
  }
}
uroshercog/cloudstan-r documentation built on Dec. 23, 2021, 2:03 p.m.