library(rpkgkit)
dir <- file.path(tempdir(), "example")
usethis::create_package(dir, open = FALSE)
usethis::local_project(dir)
usethis::use_readme_md(open = FALSE)rpkgkit includes utilities that can also be imported
directly into another project with
usethis::use_standalone().
The args_to_func.R standalone script provides helpers
for matching a list of arguments to compatible functions.
The caller_cli.R standalone script decorates a
cli function so its output identifies the caller.
The colorful_cli.R standalone script creates a
cli environment with convenient color classes.
color_cli <- create_colorful_cli_env()
color_cli$cli_alert_danger("{.red This is a red message}")
color_cli$cli_alert_info("{.blue This is a blue message}")
color_cli$cli_alert_info("{.orange This is an orange message}")
color_cli2 <- create_colorful_cli_env(cli_theme = generate_color_theme())
color_cli2$cli_alert_success(
"{.violetred3 R}{.orange a}{.yellow i}{.green n}{.cyan b}{.blue o}{.purple w}"
)Use inquire_standalone() to inspect standalone files in
a GitHub repository and browse_standalone() to search
supported repositories.
try(inquire_standalone("r-lib/rlang"))
#> # A tibble: 13 × 9
#> name path sha size url html_url git_url download_url type
#> <chr> <chr> <chr> <int> <chr> <chr> <chr> <chr> <chr>
#> 1 standalone-cli.R R/st… 14c6… 18672 http… https:/… https:… https://raw… file
#> 2 standalone-downs… R/st… 09b7… 9213 http… https:/… https:… https://raw… file
#> 3 standalone-lazye… R/st… 50ce… 2313 http… https:/… https:… https://raw… file
#> 4 standalone-lifec… R/st… 70f0… 6411 http… https:/… https:… https://raw… file
#> 5 standalone-linke… R/st… 9ab2… 2167 http… https:/… https:… https://raw… file
#> 6 standalone-obj-t… R/st… e9c3… 7175 http… https:/… https:… https://raw… file
#> 7 standalone-purrr… R/st… 0c1d… 5501 http… https:/… https:… https://raw… file
#> 8 standalone-rlang… R/st… 4da3… 1807 http… https:/… https:… https://raw… file
#> 9 standalone-s3-re… R/st… 05f0… 6056 http… https:/… https:… https://raw… file
#> 10 standalone-sizes… R/st… 03ee… 3069 http… https:/… https:… https://raw… file
#> 11 standalone-types… R/st… 42c7… 6843 http… https:/… https:… https://raw… file
#> 12 standalone-vctrs… R/st… a789… 14292 http… https:/… https:… https://raw… file
#> 13 standalone-zeall… R/st… 5e9d… 843 http… https:/… https:… https://raw… filetry(browse_standalone())
#> ℹ Searching GitHub for standalone-*.R files
#> Error in gh::gh("/search/code", q = "filename:standalone- language:R -filename:import-", :
#> GitHub API error (429): try again in 53.596538884s
#> ℹ Read more at <https://docs.github.com/rest/search/search#search-code>Create a local standalone file with a standard metadata header:
After editing standalone files, refresh their
last-updated field:
Add a dated changelog entry to one or more standalone files: