-
Notifications
You must be signed in to change notification settings - Fork 12
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
Cliff notes about the cli package - R-hub blog #169
Comments
I'm just starting with cli, so this post is excellent! I have two questions:
|
👋 @peterdesmet! Thanks for your comment. Cc @drmowinckels
cli::cli_alert(c(
"This {.val text} is longer than 80 characters in my code, so I wrap it with",
"{.fun paste}."
))
#> → This "text" is longer than 80 characters in my code, so I wrap it with`paste()`. Created on 2023-12-22 with reprex v2.0.2 |
I'm not sure I understand the question. Does https://www.njtierney.com/post/2023/12/06/long-errors-smell/ help at all? |
library(cli)
cli::cli_abort(c(
"This {.val text} is longer than 80 characters in my code, so I wrap it with",
"{.fun paste}."
))
#> Error:
#> ! This "text" is longer than 80 characters in my code, so I wrap it with
#> `paste()`.
#> Backtrace:
#> ▆
#> 1. └─cli::cli_abort(...)
#> 2. └─rlang::abort(...) at cli/R/rlang.R:45:3
cli::cli_abort(paste(
"This {.val text} is longer than 80 characters in my code, so I wrap it with",
"{.fun paste}."
))
#> Error:
#> ! This "text" is longer than 80 characters in my code, so I wrap it with
#> `paste()`.
#> Backtrace:
#> ▆
#> 1. └─cli::cli_abort(...)
#> 2. └─rlang::abort(...) at cli/R/rlang.R:45:3 Created on 2023-12-22 with reprex v2.0.2 |
@peterdesmet you can also write a multi-line string instead of cli::cli_alert(
"This {.val text} is longer than 80 characters in my code, so I just write it in
two lines, no need to use {.fun paste}."
) |
Ah yes then the blog post will be relevant for sure as it discusses the creation of helper functions to check arguments. Also I see https://vctrs.r-lib.org/reference/vec_assert.html but it has a "questioning" lifecycle badge. |
Cliff notes about the cli package - R-hub blog
https://blog.r-hub.io/2023/11/30/cliff-notes-about-cli/
The text was updated successfully, but these errors were encountered: