Skip to content

Commit

Permalink
Merge pull request #1462 from dbetebenner/master
Browse files Browse the repository at this point in the history
Cleaning up tabs in zzz.R
  • Loading branch information
dbetebenner authored Dec 5, 2024
2 parents afcdb73 + 115c9b3 commit d74560a
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ function(libname, pkgname) {

`.onAttach` <- function(libname, pkgname) {
if (interactive()) {

# Function to get the development version
# Utility function
get_dev_version <- function(package) {
url <- paste0("https://raw.githubusercontent.com/CenterForAssessment/", package, "/refs/heads/master/DESCRIPTION")
tryCatch({
Expand All @@ -26,28 +25,25 @@ function(libname, pkgname) {
})
}


# Extract version information
installed.version <- utils::packageDescription("SGP")[['Version']]
cran.version <- tryCatch(
pkgsearch::cran_package("SGP")[['Version']],
error = function(e) "Unavailable",
warning = function(w) "Unavailable"
)
warning = function(w) "Unavailable")
dev.version <- get_dev_version("SGP")

# Define a friendly startup message
message_text <- paste0(
magenta(bold("\uD83C\uDF89 SGP v", installed.version, sep="")), " - ", toOrdinal::toOrdinalDate("2024-12-4"), "\n",
strrep("\u2501", 40), "\n",
bold("\U1F4E6 CRAN: "), green("v", cran.version, sep=""), "\n",
bold("\U1F527 Dev: "), cyan("v", dev.version, sep=""), "\n",
strrep("\u2501", 40), "\n",
"\U1F4A1 Tip: ", magenta(bold("> help(package=\"SGP\")")), "\n",
"\U1F310 Docs: ", magenta(bold("https://sgp.io/")), "\n",
strrep("\u2501", 40), "\n",
"\u2728 Happy SGPing!"
)
message_text <- paste0(
magenta(bold("\uD83C\uDF89 SGP v", installed.version, sep="")), " - ", toOrdinal::toOrdinalDate("2024-12-4"), "\n",
strrep("\u2501", 40), "\n",
bold("\U1F4E6 CRAN: "), green("v", cran.version, sep=""), "\n",
bold("\U1F527 Dev: "), cyan("v", dev.version, sep=""), "\n",
strrep("\u2501", 40), "\n",
"\U1F4A1 Tip: ", magenta(bold("> help(package=\"SGP\")")), "\n",
"\U1F310 Docs: ", magenta(bold("https://sgp.io/")), "\n",
strrep("\u2501", 40), "\n",
"\u2728 Happy SGPing!")

# Display the startup message
packageStartupMessage(message_text)
Expand Down

0 comments on commit d74560a

Please sign in to comment.