M R/quote-console.R => R/quote-console.R +7 -2
@@ 2,15 2,20 @@
#'
#' @md
#' @param faction faction (see [random_quote()])
+#' @param foreground should the foreground text be in black or white (defaults to `white`).
#' @export
-quote_console <- function(faction = NULL) {
+quote_console <- function(faction = NULL, foreground = c("white", "black")) {
+
+ foreground <- match.arg(foreground[1], c("white", "black"))
x <- random_quote(faction)
cw <- cli::cli_sitrep()$console_width
+ q <- strwrap(x$starWarsQuote, width = cw)
+
cli::boxx(
- label = crayon::white(strwrap(x$starWarsQuote, width = cw)),
+ label = switch(foreground, white = crayon::white(q), black = crayon::black(q)),
width = cw,
float = "center",
border_col = "gold1"
M R/random-quote.R => R/random-quote.R +3 -1
@@ 13,7 13,9 @@ random_quote <- function(faction = NULL) {
if (!is.null(faction)) {
faction <- as.integer(faction[1])
- stopifnot(faction %in% 0L:4L)
+ if ((faction < 0) || (faction > 4)) {
+ stop("'faction' must be 0:4")
+ }
}
httr::GET(
M man/quote_console.Rd => man/quote_console.Rd +3 -1
@@ 4,10 4,12 @@
\alias{quote_console}
\title{Get a random Star Wars quote and display it stylishly to the console}
\usage{
-quote_console(faction = NULL)
+quote_console(faction = NULL, foreground = c("white", "black"))
}
\arguments{
\item{faction}{faction (see \code{\link[=random_quote]{random_quote()}})}
+
+\item{foreground}{should the foreground text be in black or white (defaults to \code{white}).}
}
\description{
Get a random Star Wars quote and display it stylishly to the console