Skip to content

Commit eb3a8a3

Browse files
committed
simplify user-input checks
1 parent f7e50d5 commit eb3a8a3

File tree

2 files changed

+9
-26
lines changed

2 files changed

+9
-26
lines changed

R/query_parameters.R

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,31 +61,14 @@ query_parameters <- function(
6161
community_vals <- c("AG", "RE", "SB")
6262
temporal_api_vals <- c("DAILY", "MONTHLY", "HOURLY", "CLIMATOLOGY")
6363

64-
# if the args for `community` and `temporal_api` are not empty, check and
65-
# then reset `community_vals` and `temporal_api_vals` for use later
64+
community <- tolower(community)
65+
temporal_api <- tolower(temporal_api)
6666

67-
if (!is.null(community)) {
68-
community <- toupper(community)
69-
70-
if (community %notin% community_vals) {
71-
cli::cli_abort(c(
72-
x = "{.arg community} does not match any valid values for {.var community}."
73-
))
74-
}
75-
community_vals <- community
76-
}
77-
78-
if (!is.null(temporal_api)) {
79-
temporal_api <- toupper(temporal_api)
80-
if (temporal_api %notin% temporal_api_vals) {
81-
cli::cli_abort(
82-
c(
83-
x = "{.arg temporal_api} does not match any valid values for {.var temporal_api}."
84-
)
85-
)
86-
}
87-
temporal_api_vals <- temporal_api
88-
}
67+
community <- rlang::arg_match(community, c("ag", "re", "sb"))
68+
temporal_api <- rlang::arg_match(
69+
temporal_api,
70+
c("daily", "monthly", "hourly", "climatology")
71+
)
8972

9073
if (!is.null(pars)) {
9174
pars <- toupper(pars)

codemeta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"name": "R",
1414
"url": "https://r-project.org"
1515
},
16-
"runtimePlatform": "R version 4.5.0 (2025-04-11)",
16+
"runtimePlatform": "R version 4.5.1 (2025-06-13)",
1717
"provider": {
1818
"@id": "https://cran.r-project.org",
1919
"@type": "Organization",
@@ -273,7 +273,7 @@
273273
"applicationCategory": "Tools",
274274
"isPartOf": "https://ropensci.org",
275275
"keywords": ["NASA", "meteorological-data", "weather", "global", "weather-data", "meteorology", "NASA-POWER", "agroclimatology", "earth-science", "data-access", "climate-data", "r", "nasa-power", "nasa", "agroclimatology-data", "weather-variables", "rstats", "r-package"],
276-
"fileSize": "505.759KB",
276+
"fileSize": "505.207KB",
277277
"citation": [
278278
{
279279
"@type": "ScholarlyArticle",

0 commit comments

Comments
 (0)