Comments (5)
You can always catch all messages, if that helps with your use case:
❯ msgs <- list(); withCallingHandlers(cli::cli_inform("good to know"), message = function(m) msgs <<- c(msgs, list(m)))
good to know
❯ msgs
[[1]]
<message/rlang_message>
Message:
good to know
from cli.
Yes, that's a mistake in the documentation, those functions indeed do not use the regular cli code path.
from cli.
Thanks for the clarification.
Wondering if something like this might be a palatable alternative:
alt_inform <- function(message, ..., .envir = parent.frame()) {
outer_cnd <- catch_cnd(
rlang::inform(cli::format_message(message, .envir = .envir), ...)
)
cnd <- catch_cnd(
cli::cli_verbatim(
format(outer_cnd)
)
)
handler <- getOption("cli.default_handler", cli:::cli_server_default)
handler(cnd)
cnd_signal(outer_cnd)
invisible(NULL)
}
from cli.
cli_inform()
is basically the same as cli_bullets()
, so you can probably use that instead.
from cli.
My hope was to use the default handler functionality to intercept cli_* calls and reroute them into a log. In general, I wouldn't have access to the source code that invokes the cli_* calls.
Seems like it wasn't designed for this use case. No worries. Thanks for the comments.
from cli.
Related Issues (20)
- `code_theme_default()` errors when in RStudio, but without {rstudioapi}
- Release cli 3.6.3
- Suggestions for printing tibble preview in `cli_abort`? HOT 2
- Provide helper for making reproducible output
- Pluralisation fails for infinite values HOT 1
- Styling is preserved in HTML output, but not supported HOT 5
- `cli_fmt()` does not capture output for `cat_()` functions HOT 3
- Use `testthat::with_mock()` instead of mockery
- `{.run ...}` will not allow a custom function to be clickable if its name contains a `.` HOT 1
- [feature] Inline formatting for percentages
- cli_alter_* with cat(), symbols positioned at end of output HOT 4
- Document `cli.default_handler` option
- Is `cli_progress_along()` still experimental?
- `col_grey()` and `col_silver()` is unreadable in Positron (Tomorrow Night Blue theme) HOT 5
- default bullet type for abort/error is a warning HOT 1
- link text for files does not display properly with `fs_path` objects
- mark `cli_alert*()` functions as superseded HOT 2
- NAs in pluralize vector cause values to not display correctly HOT 3
- STRING_PTR_RO means R dependency is 3.5.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cli.