This will set the envvar R_CLI_NUM_COLORS to n_colors within the scope of .local_envir. To avoid sideeffects through overriding crayon::has_color(), this function only works on_github().

enable_github_colors(
  n_colors = as.integer(256^3),
  .local_envir = parent.frame(),
  quiet = FALSE
)

disable_github_colors(.local_envir = parent.frame(), quiet = FALSE)

Arguments

n_colors

An integer giving the number of colors. Default 24bit.

.local_envir

[environment]
The environment to use for scoping.

quiet

Should messages be printed?

Value

Invisibly returns TRUE if enabling/disabling was successful, FALSE otherwise.

Examples

Sys.setenv(GITHUB_ACTIONS = "true")
enable_github_colors()
#> Error in enable_github_colors(): could not find function "enable_github_colors"
Sys.setenv(GITHUB_ACTIONS = "false")
enable_github_colors()
#> Error in enable_github_colors(): could not find function "enable_github_colors"