Last active
October 10, 2019 12:12
-
-
Save tonyelhabr/9bc3ae77aba4b2cd19bbc88c5c17babb to your computer and use it in GitHub Desktop.
R functions for displaying information, warnings, and errors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.verbose <- TRUE | |
.display_info <- function(x, ..., .envir = parent.frame(), verbose = .verbose) { | |
if(!verbose) { | |
return(invisible(NULL)) | |
} | |
# usethis::ui_line(glue::glue('{x}'), .envir = .envir) | |
# Reference: `usethis::ui_line()` | |
x <- glue::glue_collapse(x, '\n') | |
x <- glue::glue(x, .envir = .envir) | |
cli::cat_line(x) | |
} | |
# NOTE: Ignore `verbose` for these. | |
.display_warning <- function(x, ..., .envir = parent.frame(), verbose = .verbose) { | |
usethis::ui_warn(x, .envir = .envir) | |
} | |
.display_error <- function(x, ..., .envir = parent.frame(), verbose = .verbose) { | |
usethis::ui_stop(x, .envir = .envir) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment