Skip to content

Commit

Permalink
account for when 0 notes/warns are found
Browse files Browse the repository at this point in the history
  • Loading branch information
RossanaTat committed Sep 25, 2024
1 parent f18bd38 commit eee5ab3
Showing 1 changed file with 43 additions and 19 deletions.
62 changes: 43 additions & 19 deletions R/joyn-merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -541,15 +541,6 @@ joyn <- function(x,
joyn_report(verbose = verbose)

if (verbose == TRUE) {
#joyn_msg(msg_type)

# notes_count <- sum(
# .joynenv$joyn_msgs$type %in% c("info", "note")
# )
#
# warn_count <- sum(
# .joynenv$joyn_msgs$type == "warn"
# )

type_element <- rlang::env_get(.joynenv,
"joyn_msgs")$type
Expand All @@ -560,33 +551,66 @@ joyn <- function(x,
notes_count <- fsum(type_element %in% c("info", "note"),
na.rm = TRUE)

# notes_count <- sum(
# .joynenv$joyn_msgs$type %in% c("info", "note")
# )
#
# warn_count <- sum(
# .joynenv$joyn_msgs$type == "warn"
# )


warning_type <- "warn"
info_type <- "info"
note_type <- "note"

# option 2 -clickable x and y warnings

## show messages ------------------

# get output method option
output_method <- getOption("joyn.output_method")

if (output_method == TRUE) {
cli::cli_li(
sprintf(
"Joyn returned {.run [{.strongArg {notes_count} notes}](joyn::joyn_msg('%s'))} and raised
{.run [{.strongArg {warn_count} warnings}](joyn::joyn_msg('%s'))}
",
info_type, warning_type

if (notes_count > 0 || warn_count > 0) {

cli::cli_text("Joyn returned:")

# notes
cli::cli_li(
sprintf(
"{.run [{.strongArg {notes_count} notes}](joyn::joyn_msg('%s'))}
",
info_type
)
)

# warnings
cli::cli_li(
sprintf(
"
{.run [{.strongArg {warn_count} warnings}](joyn::joyn_msg('%s'))}
",
warning_type
)
)
)


}
# cli::cli_li(
# sprintf(
# "Joyn returned {.run [{.strongArg {notes_count} notes}](joyn::joyn_msg('%s'))} and raised
# {.run [{.strongArg {warn_count} warnings}](joyn::joyn_msg('%s'))}
# ",
# info_type, warning_type
# )
# )
} else {
joyn_msg(msg_type)
}

}


}
setattr(jn, "class", class_x)

jn
Expand Down

0 comments on commit eee5ab3

Please sign in to comment.