From 5d5a69f5456701d60d617a6c0098e24bf26496b6 Mon Sep 17 00:00:00 2001 From: Kenneth Blake Vernon <53311626+kbvernon@users.noreply.github.com> Date: Sat, 7 Sep 2024 11:16:07 -0600 Subject: [PATCH] update checks on version parameter Co-authored-by: Josiah Parry --- R/use_msrv.R | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/R/use_msrv.R b/R/use_msrv.R index 2e3a8132..c784eb3f 100644 --- a/R/use_msrv.R +++ b/R/use_msrv.R @@ -17,12 +17,18 @@ #' use_msrv <- function(version = NULL, path = "."){ - if (is.null(version)){ + if (length(version) != 1L) { + cli::cli_abort("Version must be a character scalar", class = "rextendr_error") + } + + msrv_call <- rlang::caller_call() + version <- tryCatch(numeric_version(version), error = function(e) { cli::cli_abort( - "Minimum supported Rust {.arg version} not specified.", - class = "rextendr_error" + "Invalid version provided", + class = "rextendr_error", + call = msrv_call ) - } + }) desc_path <- rprojroot::find_package_root_file("DESCRIPTION", path = path)