Closed pawelru closed 3 months ago
is https://rlang.r-lib.org/reference/is_interactive.html relevant to your use case?
Actually, I was wrong. This is fully functional.
interactive <- NULL
interactive()
#> [1] FALSE
`if`(interactive(), 1, 2)
#> [1] 2
Created on 2024-03-26 with reprex v2.1.0
And thanks for a good resource. I think it would be nice to link it somewhere in https://testthat.r-lib.org/reference/local_mocked_bindings.html?q=interactive#base-functions. For now, closing this.
Currently the guide recommends to set
interactive <- NULL
but I think it's safer to keep it as function and dointeractive <- base::interactive
instead. It's important when there is a function call in the package code, i.e.if (interactive()) ...
. If set toNULL
this would throw.