Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft compat file for cli #1201

Merged
merged 3 commits into from
May 12, 2021
Merged

Draft compat file for cli #1201

merged 3 commits into from
May 12, 2021

Conversation

lionel-
Copy link
Member

@lionel- lionel- commented May 11, 2021

And use style_arg() in arg.R messages.

@lionel- lionel- requested a review from gaborcsardi May 11, 2021 15:27
R/compat-cli.R Outdated

.rlang_cli_style <- function(x, span, fallback = "`%s`") {
if (requireNamespace("cli") && cli::num_ansi_colors() > 1) {
cli::format_message(paste0("{.", span, " ", x, "}"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will fail if x has { or }. Let cli do the interpolation instead:

x <- "{{{"
span <- "emph"
cat(cli::format_message(paste0("{.", span, " ", x, "}")))
#> Error in glue_data(.x = NULL, ..., .sep = .sep, .envir = .envir, .open = .open,  :
#>  Expecting '}'
cat(cli::format_message(paste0("{.", span, " {x}}")))
#> {{{

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh of course. If I fall in the trap right after discussing the issue, then it's a good thing we have decided to guard against this.

@lionel- lionel- merged commit 667a290 into r-lib:master May 12, 2021
@lionel- lionel- deleted the compat-cli branch May 12, 2021 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants