Title: | Simplify Output Verbosity |
---|---|
Description: | Simplifies output suppression logic in R packages, as it's common to develop some form of it in R. 'quietR' intends to simplify that problem and allow a set of simple toggle functions to be used to suppress console output. |
Authors: | Thomas Johnson [aut, cre] |
Maintainer: | Thomas Johnson <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.0 |
Built: | 2024-11-23 05:33:43 UTC |
Source: | https://github.com/thomascjohnson/quietr |
Masked output functions (cat, message, print) that can be toggled with [verbosity] functions. Instead of implementing your own verbose handling system, use quietR.
cat(...) message(...) print(...)
cat(...) message(...) print(...)
... |
Arguments passed to masked output function |
print("Hello World!") disable_verbose() print("Hello World!")
print("Hello World!") disable_verbose() print("Hello World!")
Use the 'is_verbose', 'enable_verbose' and 'disable_verbose' to toggle console output functions.
enable_cat() disable_cat() enable_message() disable_message() enable_print() disable_print() is_verbose(func = c("print", "cat", "message")) enable_verbose(func = c("print", "cat", "message")) disable_verbose(func = c("print", "cat", "message"))
enable_cat() disable_cat() enable_message() disable_message() enable_print() disable_print() is_verbose(func = c("print", "cat", "message")) enable_verbose(func = c("print", "cat", "message")) disable_verbose(func = c("print", "cat", "message"))
func |
character - which function(s) to enable |
logical, whether or not to output specified function
# Returns FALSE: is_verbose("print") #FALSE enable_verbose() # Now it returns TRUE: is_verbose("print") #TRUE disable_verbose() # Now it returns FALSE: is_verbose() #FALSE is_verbose("print") #FALSE enable_verbose("print") print("Hi there!") # Outputs cat("I won't output") # Doesn't output
# Returns FALSE: is_verbose("print") #FALSE enable_verbose() # Now it returns TRUE: is_verbose("print") #TRUE disable_verbose() # Now it returns FALSE: is_verbose() #FALSE is_verbose("print") #FALSE enable_verbose("print") print("Hi there!") # Outputs cat("I won't output") # Doesn't output