You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks again for maintaining cli, I feel like I am still discovering nice new features all the time (like diff_chr and diff_str recently!).
I'm wondering if there is an argument to be had for a "last" argument to cli_abort and friends?
Currently the output is limited to using "and".
I can use rlang::arg_match to solve this particular problem, but it feels like a last argument could be something that is more generally useful?
check_valid_fruit<-function(fruit) {
valid_fruits<- c("apples", "bananas")
is_valid_fruit<-fruit%in%valid_fruitsif (!is_valid_fruit) {
cli::cli_abort(
message="{.var {fruit}} must be one of {.var {valid_fruits}}"# potential argument option?# .last = "or"
)
}
}
check_valid_fruit("apples")
check_valid_fruit("lemons")
#> Error in `check_valid_fruit()`:#> ! `lemons` must be one of `apples` and `bananas`# this does what I want, but sometimes we don't always want to use # arg matching?check_valid_fruit_arg<-function(fruit) {
rlang::arg_match0(fruit, c("apples", "bananas"))
}
check_valid_fruit_arg("apples")
#> [1] "apples"
check_valid_fruit_arg("lemons")
#> Error in `check_valid_fruit_arg()`:#> ! `fruit` must be one of "apples" or "bananas", not "lemons".
Hello!
Thanks again for maintaining
cli
, I feel like I am still discovering nice new features all the time (likediff_chr
anddiff_str
recently!).I'm wondering if there is an argument to be had for a "last" argument to
cli_abort
and friends?Currently the output is limited to using "and".
I can use
rlang::arg_match
to solve this particular problem, but it feels like a last argument could be something that is more generally useful?Created on 2024-03-12 with reprex v2.1.0
Session info
Initially posted about this here: https://community.rstudio.com/t/cli-package-using-or-instead-of-and-as-last-separator/183142/4
The text was updated successfully, but these errors were encountered: