Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new simple internal options and verbosity level #29

Merged
merged 69 commits into from
Jan 13, 2025

Conversation

akselthomsen
Copy link
Contributor

@akselthomsen akselthomsen commented Jan 8, 2025

Large update of zephyr

  • Aim is to be the basis of our first CRAN release.
  • Due to internal requirements of supporting older R versions it implements basic functionality to work with package specific options similar to the ones previously used from {options} package. In documentation it has been noted that our implementation is just targeted our needs, and we recommend {options} for general usage.
  • Verbosity level is updated to be created as a package option, and the get_verbosity_level() functions are now based on get_option().
  • A utility function use_zephyr() has been added to easily setup the above in your package.
  • Documentation has been updated with new functions.
  • Updated tests as well, so we now have 100% test coverage, and a simplistic integration test where zephyr is used in a new package. The Suggest imports of callr and devtools are due to this test. There may be a way to achieve the same with less imports.

LVGK (Lovemore Gakava) and others added 30 commits November 22, 2024 19:02
options::as_params()
options::envvar_is_true()
options::envvar_str_split(delim = ";")
…, fails since the package environment is locked. Updating to have the option set at global level.
@akselthomsen akselthomsen marked this pull request as ready for review January 9, 2025 13:54
@akselthomsen akselthomsen mentioned this pull request Jan 10, 2025
Copy link

@Lovemore-Gakava Lovemore-Gakava left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose modifying the msg function to utilize cli::cli_alert instead of its current use of cli::cli_alert_info. This change would allow us to create a distinction between the general msg function and a more specific msg_info function. As an example:

> foo <- function() {
+   msg_debug("Some important debug information about the function")
+   msg("Starting calculations")
+  
+   result <- 1 + 1 # Replace with long calculations and how to create output
+   
+   msg("getting output creation status")
+   
+   if (result == 2) {
+     msg_success("Output created")
+   } else {
+     msg_danger("Output not created correctly")
+   }
+   
+   return(result)
+ }
> 
> withr::with_options(
+   new = list(zephyr.verbosity_level = "debug"),
+   code = foo()
+ )
ℹ Some important debug information about the function
→ Starting calculations
→ getting output creation status
✔ Output created
[1] 2

R/msg.R Outdated Show resolved Hide resolved
Copy link

Code coverage

Name Coverage (%)
zephyr 98.48
R/checkmate.R 100.00
R/msg.R 100.00
R/options.R 100.00
R/use_zephyr.R 100.00
R/utils.R 100.00
R/verbosity_level.R 100.00
R/zzz.R 0.00

Copy link

Github pages

Review the pkgdown webpage for the PR here

@akselthomsen akselthomsen merged commit 80dcead into main Jan 13, 2025
13 of 14 checks passed
@akselthomsen akselthomsen deleted the feat/simple-options branch January 13, 2025 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement options functionalities feature: Add configuration options for verbosity levels
2 participants