Skip to content

Commit

Permalink
reuseme.global_todo implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed Aug 5, 2024
1 parent a5180b5 commit 0e72fb5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: reuseme
Title: Collections of Utility Functions to Work Across Projects
Version: 0.0.2.9005
Version: 0.0.2.9006
Authors@R:
person("Olivier", "Roy", , "olivierroy71@hotmail.com", role = c("aut", "cre"))
Description: Allows you to browse current projects, rename files safely,
Expand Down Expand Up @@ -42,4 +42,4 @@ Suggests:
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ that will passed on to `proj_list()`

* `file_outline()` result is now a simpler data frame. The cli links are now created in the print method. (which makes more sense for truncation)

* `use_todo("global::todo")` no longer works out of the box. You need to set `options(reuseme.global_todo = fs::path("Documents"))` explicitly (in .Rprofile) for example to make sure
reuseme can write in a directory.

## Fixes

* `rename_files2()` now looks in `.Rbuildignore` to see if some files should be replaced.
Expand Down
14 changes: 12 additions & 2 deletions R/todo.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
#' use `usethis::use_git_ignore("TODO.R")` if you don't want your `TODO.R` file
#'
#' to be included in git. If using in a package directory, use
#' `usethis::use_build_ignore("TODO.R")` to prevent a note in `R CMD CHECK`
#' `usethis::use_build_ignore("TODO.R")` to prevent a note in `R CMD CHECK`.
#'
#' If you want to write to a global TODO, use
#'
#' `options(reuseme.global_todo = fs::path("Documents"))` to write there.
#'
#' @param todo A character vector of lines to add to the TODO file. See details
#' for special handling.
Expand Down Expand Up @@ -219,7 +223,13 @@ compute_path_todo <- function(todo, proj) {

# Handle special global and all syntax for todo items.
if (proj %in% c("global", "all")) {
proj_path <- Sys.getenv("R_USER", Sys.getenv("HOME")) # ?base::path.expand
proj_path <- getOption("reuseme.global_todo")
if (is.null(proj_path)) {
cli::cli_abort(c(
"You must set a global option reuseme.global_todo to write to a global todo.",
i ="A good option for cross-platform is `options(reuseme.global_todo = fs::path_home(\"Documents\"))"
))
}
} else if (!is_active_proj) {
# in interactive session with options set
proj_path <- proj_list(proj)
Expand Down
4 changes: 4 additions & 0 deletions man/filter_detect.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/use_todo.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0e72fb5

Please sign in to comment.