For point 1, I see how that would be useful, have you considered an enum: verbose_compute = c("step1","step3")
, that way you’d be able to keep your user interface constant when the number of steps change. In that same vein, you could still do this with options I suppose, but that might be less user friendly? Very interesting!
For point 2, have you considered withr? Options — with_options • withr, that’ll save you from setting and resetting options. Like you I am also a bit reluctant to change global state where I can avoid it.
For point 3, using cat()
for user messaging is difficult to suppress and more difficult to write good tests for, which is why it is recommended against in the [rOpenSci Build Guide](Chapter 1 Packaging Guide | rOpenSci Packages: Development, Maintenance, and Peer Review. It’s certainly caused me issues before.
I believe you’d be better off using cli::cli_inform() and setting ANSI NO_COLOR as an option, possibly with withr.
What do you think?