R/say_aloha.R

#' Say Aloha
#'
#' @description This function will say aloha to any inputted name.
#'
#' @param name (character) A name to say aloha to.
#' @param print (logical) Option to print your message. Defaults to \code{TRUE}
#'
#' @return (character) An aloha message
#'
#' @examples
#' # Say hello to a friend
#' friend <- "Irene"
#' say_aloha(friend)
#'
#' @importFrom crayon bgGreen
#' @importFrom emo ji
#'
#' @export
say_aloha <- function(name, print = TRUE) {

  if (!all(is.character(name) & nchar(name) > 0)) {
    stop("Name must be a non empty character.
         Input a name you want to say aloha to!")
  }
  #stopifnot(is.logical(print)) ##stops function if print != TRUE or FALSE
  stopifnot(is.logical(print))

  message <- paste("Aloha,",
                   name,
                   emo::ji("palm_tree"),
                   emo::ji("sunny"),
                   emo::ji("ocean"))

  if (print) {
    cat(crayon::bgGreen(message))
  }

  invisible(message)
  }
eringutbrod/greetings documentation built on May 28, 2019, 2:31 a.m.