cynkra / constructive

Display Idiomatic Code to Construct Most R Objects
https://cynkra.github.io/constructive
Other
131 stars 6 forks source link

Console message for `construct_clip()`? #486

Open wurli opened 2 months ago

wurli commented 2 months ago

How would you feel about the idea of adding some console messages to construct_clip()? Currently there's nothing to signal to a user that anything about the global state has changed, which to me feels like a bit of a sharp edge.

I'd suggest displaying the complete text of the copied code, e.g:

constructive::construct_clip(letters)
#> ℹ Construct code has been added to the clipboard:
#> ``` r
#> c(
#>   "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
#>   "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
#> )
#> ```

A more terse message might be something like ℹ Added 4 lines to the clipboard, but I think showing the full code is better.

Here's why I think more messaging would be useful:

Happy to make a PR if you like this idea.

I'm really enjoying this package! Thanks for creating/maintaining it 😃

moodymudskipper commented 2 months ago

This sounds good to me thanks! I'm happy to review a PR

wurli commented 2 months ago

Nice, thanks! Just putting one together now. I noticed that {prettycode} is required for syntax highlighting, but I think this can be removed in favour of cli::code_highlight() (introduced in cli 3.1.0) since cli is already a dependency. Happy for me to make that change as part of the same PR?

moodymudskipper commented 2 months ago

Interesting, it seems to do the same except that cli adds hyperlinks to help files with hover on info. Yes that'd be great to do the switch, then no need to check if prettycode is installed as we now do. I would prefer this in a separate PR however if you don't mind. Add yourself to ctb too in the first PR.

wurli commented 2 months ago

Nice one, will do 👍