r-lib / cli

Tools for making beautiful & useful command line interfaces
https://cli.r-lib.org/
Other
624 stars 66 forks source link

Suggestions for printing tibble preview in `cli_abort`? #699

Open dshemetov opened 1 week ago

dshemetov commented 1 week ago

Hello there. Thank you for your work on this package!

Do you have any suggestions for how to include tibble previews in error messages? Currently, our work around is something along the lines of: use the built-in tibble print with capture output, collapse the resulting character vector with newlines, and then insert that into a cli_abort message. Are there more ergonomic ways to do this or perhaps a different set of best practices?

We use cli in the internals of a time series forecasting package built on top of tidymodels, where it is very helpful to print the data context in an error because errors often stem from data anomalies.

cc @brookslogan

gaborcsardi commented 1 week ago

I don't think this is possible currently, unfortunately. cli_abort() prints a list of bullet points, where each bullet point is a paragraph that can only have inline formatting.