diff --git a/R/init-pal.R b/R/init-pal.R index cf54efd..b8bf8e9 100644 --- a/R/init-pal.R +++ b/R/init-pal.R @@ -48,7 +48,7 @@ ..., .ns = "elmer" ) { - check_role(role) + check_role(role, allow_default = TRUE) if (!role %in% list_pals()) { cli::cli_abort(c( "No pals with role {.arg {role}} registered.", diff --git a/R/utils.R b/R/utils.R index 389bcee..ef088fb 100644 --- a/R/utils.R +++ b/R/utils.R @@ -32,7 +32,9 @@ list_pals <- function() { } # ad-hoc check helpers ------- -check_role <- function(role, call = caller_env()) { +check_role <- function(role, + allow_default = !is.null(getOption(".pal_on_load")), + call = caller_env()) { check_string(role, allow_empty = FALSE, call = call) if (!is_valid_role(role)) { @@ -42,7 +44,7 @@ check_role <- function(role, call = caller_env()) { ) } - if (role %in% default_roles & is.null(getOption(".pal_on_load"))) { + if (role %in% default_roles & !allow_default) { cli::cli_abort( "Default roles cannot be edited or removed.", call = call