Open mattmalin opened 4 years ago
Will want to make the colouring optional to add to randomcolour()
as coloured if crayon present, so may use of conditional following e.g. https://stackoverflow.com/questions/48266553/fallback-and-optional-dependencies-in-r-packages-the-cran-way
In progress example to allow randomcolour()
itself to work whether crayon present or not:
randomcolour_better <- function()
{
hex_value <- as.character.hexmode(sample(2^24, 1) - 1, 1)
hex_colour <- paste0(
"#",
paste0(rep("0", times = 6 - nchar(hex_value)), collapse = ""),
toupper(hex_value))
if (requireNamespace("crayon", quietly=TRUE)) {
cat(crayon::make_style(hex_colour)(hex_colour))
return(invisible(hex_colour))
} else {
return(hex_colour)
}
}
Want to have a
randomcolour_crayon()
andrandomcolour_message
which colours the messages themselves either with colour as string or provided message.May want to make the standard output of
randomcolour()
be coloured, though could add a strong dependency, so likely want it to be optional.