Commit 9c723cad authored by Eric Coissac's avatar Eric Coissac

Adds a new robimessage function

parent 5b0fbd9c
......@@ -88,8 +88,10 @@ combine_LETTERS <- function(n,
#'
is_robi_verbose <- function()
{
isTRUE(getOption("ROBITools2.verbose")) && interactive() &&
!isTRUE(getOption("rstudio.notebook.executing")) && !isTRUE(getOption("knitr.in.progress"))
isTRUE(getOption("ROBITools2.verbose")) &&
interactive() &&
!isTRUE(getOption("rstudio.notebook.executing")) &&
!isTRUE(getOption("knitr.in.progress"))
}
......@@ -132,6 +134,46 @@ robiassert_arg <- function(predicat,arg,message,..., .envir = parent.frame(), .a
robiassert(predicat,message,...,.envir = .envir, .abort = .abort)
}
#' Writes a message on the console in verbose mode
#'
#' The message is written to the console if the code
#' is executed in the verbose mode. The verbose mode
#' can be specified by declaring a `verbose` logical
#' value to `TRUE`. If no `verbose` variable is defined,
#' the result of the `ROBITools2::is_robi_verbose`
#' function is used to decide of the verbose status.
#'
#'
#' @param message a string template sent to the `glue::glue` preprocessor.
#' @param ... other values to be concatenated to the end of the message
#' @param .envir the environment passed to the `glue::glue` preprocessor
#'
#' @md
#' @export
#'
#' @examples
#' verbose = TRUE
#' robimessage("Hello world !")
#' verbose = FALSE
#' robimessage("Hello world !")
#' rm(verbose)
#' v_mode = is_robi_verbose()
#' v_mode
#' robimessage("Hello world !")
#' options(ROBITools2.verbose = FALSE)
#' robimessage("Hello world !")
#' options(ROBITools2.verbose = TRUE)
#' robimessage("Hello world !")
#' options(ROBITools2.verbose = v_mode)
robimessage <- function(message,..., .envir = parent.frame()) {
if (!exists("verbose"))
verbose <- is_robi_verbose()
if (verbose) {
message(glue(message,..., .envir = .envir))
}
}
#' @export
clone <- function(object) {
UseMethod("clone",object)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment