Open mikmart opened 7 months ago
Alternatively,
Could arg_match()
also trim down the number of choices if there are many, like cli does with its {.or }
arg_match0("28", as.character(1:27))
#> Error:
#> ! `"28"` must be one of "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
"21", "22", "23", "24", "25", "26", or "27", not "28".
#> ℹ Did you mean "18"?
cli::cli_text("{.or {.str {as.character(1:27)}}}")
#> "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", …, "26", or "27"
Sometimes I need to match an argument against a long (100+) list of valid values. Currently the
arg_match()
error message will be overwhelmed by listing out all possible valid values. In such cases, it would be useful to have a way to include the expression from the formal argument in the message instead.For example with:
It would be nice to be able to instead get: