Skip to content

Commit

Permalink
wrap and set cli.width option
Browse files Browse the repository at this point in the history
  • Loading branch information
LiNk-NY committed Aug 14, 2024
1 parent 93012d6 commit e14c9cb
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions R/BiocCheck-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -279,17 +279,17 @@ NULL

cli_warning <- function(...) {
cli::cli_div(theme = list(.warning = list(color = "orange")))
cli::cli_alert_warning(paste0("{.warning W: ", ..., "}"))
cli::cli_alert_warning(paste0("{.warning W: ", ..., "}"), wrap = TRUE)
}

cli_error <- function(...) {
cli::cli_div(theme = list(.error = list(color = "red")))
cli::cli_alert_danger(paste0("{.error E: ", ..., "}"))
cli::cli_alert_danger(paste0("{.error E: ", ..., "}"), wrap = TRUE)
}

cli_note <- function(...) {
cli::cli_div(theme = list(.note = list(color = "blue")))
cli::cli_alert_info(paste0("{.note N: ", ..., "}"))
cli::cli_alert_info(paste0("{.note N: ", ..., "}"), wrap = TRUE)
}

# Message-class -----------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions R/BiocCheck.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,11 @@ BiocCheckRun <-
dots <- dots[[1]] # command line args come as list

oldwarn <- getOption("warn")
on.exit(options(warn=oldwarn))
options(warn=1)
oldwidth <- getOption("cli.width")
on.exit({
options(warn = oldwarn, cli.width = oldwidth)
})
options(warn = 1, cli.width = 80)

.BiocPackage <- .BiocPackage$initialize(
packageDir = package, checkDir = checkDir
Expand Down
27 changes: 16 additions & 11 deletions R/BiocCheckGitClone.R
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ BiocCheckGitClone <- function(package=".", ...)
dots <- dots[[1]] # command line args come as list

oldwarn <- getOption("warn")
on.exit(options(warn=oldwarn))
options(warn=1)
oldwidth <- getOption("cli.width")
on.exit({
options(warn = oldwarn, cli.width = oldwidth)
})
options(warn = 1, cli.width = 80)

.BiocCheck$addMetadata(.BiocPackage)
.BiocCheck$verbose <- TRUE
Expand All @@ -107,16 +110,18 @@ BiocCheckGitClone <- function(package=".", ...)
checkForCitationFile(.BiocPackage)

# BiocCheck results -------------------------------------------------------
message("\n\U2500 BiocCheck results \U2500\U2500")
.msg(
"%d ERRORS | %d WARNINGS | %d NOTES",
.BiocCheck$getNum("error"),
.BiocCheck$getNum("warning"),
.BiocCheck$getNum("note")
cli::cli_rule(
left = paste0("BiocCheck v", packageVersion("BiocCheck"), " results")
)
message(
"\nFor more details, run\n",
" browseVignettes(package = 'BiocCheck')"
cli::cli_text(
paste0(
"{symbol$cross} { .BiocCheck$getNum('error') } ERRORS | ",
"{symbol$warning} { .BiocCheck$getNum('warning') } WARNINGS | ",
"{symbol$bullet} { .BiocCheck$getNum('note') } NOTES\n"
)
)
cli::cli_alert_info(
"\nFor more details, run\n browseVignettes(package = 'BiocCheck')"
)

if (isTRUE(dots[["quit-with-status"]])) {
Expand Down
2 changes: 1 addition & 1 deletion R/util.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ handleNoteFiles <- function(..., help_text = "Found in files:") {
handleMessage <- function(..., indent=4, exdent=6)
{
msg <- paste0(...)
cli::cli_alert_info(msg)
cli::cli_alert_info(msg, wrap = TRUE)
}

installAndLoad <- function(.BiocPackage, install_dir = tempfile())
Expand Down

0 comments on commit e14c9cb

Please sign in to comment.