Skip to content

Commit 029befe

Browse files
committed
add tar_option_unset()
1 parent 077393c commit 029befe

17 files changed

+124
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Description: Pipeline tools coordinate the pieces of computationally
1212
The methodology in this package
1313
borrows from GNU 'Make' (2015, ISBN:978-9881443519)
1414
and 'drake' (2018, <doi:10.21105/joss.00550>).
15-
Version: 1.11.4.9002
15+
Version: 1.11.4.9003
1616
License: MIT + file LICENSE
1717
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
1818
BugReports: https://github.com/ropensci/targets/issues

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,7 @@ export(tar_option_export)
470470
export(tar_option_get)
471471
export(tar_option_reset)
472472
export(tar_option_set)
473+
export(tar_option_unset)
473474
export(tar_option_with)
474475
export(tar_outdated)
475476
export(tar_path)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# targets 1.11.4.9002 (development)
1+
# targets 1.11.4.9003 (development)
22

33
* Avoid loading non-targets in `tar_load(everything())` (#1529, @pitakakariki).
44
* For internal consistency, return `NA_character_` from `tar_path_target()` when `format` is `"file"` (#1532, @noamross).
5+
* Add `tar_option_unset()` (#1521, @noamross).
56

67
# targets 1.11.4
78

R/tar_option_unset.R

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#' @title Unset one or more target options.
2+
#' @export
3+
#' @family configuration
4+
#' @description Unset one or more target options you previously chose with
5+
#' [tar_option_set()]. These options are mostly configurable default
6+
#' arguments to [tar_target()] and [tar_target_raw()].
7+
#' @return `NULL` (invisibly).
8+
#' @param options A character vector of options to reset. Must all be elements of
9+
#' `names(formals(tar_option_set))`
10+
#' @examples
11+
#' tar_option_get("format") # default format before we set anything
12+
#' tar_target(x, 1)$settings$format
13+
#' tar_option_set(format = "fst_tbl") # new default format
14+
#' tar_option_get("format")
15+
#' tar_target(x, 1)$settings$format
16+
#' tar_option_unset("format") # Unsets the format option.
17+
#' tar_target(x, 1)$settings$format
18+
#' if (identical(Sys.getenv("TAR_EXAMPLES"), "true")) { # for CRAN
19+
#' tar_dir({ # tar_dir() runs code from a temp dir for CRAN.
20+
#' tar_script({
21+
#' library(targets)
22+
#' library(tarchetypes)
23+
#' tar_option_set(cue = tar_cue(mode = "always"))
24+
#' tar_option_unset("cue") # Unsets the cue option.
25+
#' list(tar_target(x, 1), tar_target(y, 2))
26+
#' })
27+
#' tar_make()
28+
#' tar_make()
29+
#' })
30+
#' }
31+
tar_option_unset <- function(options) {
32+
tar_assert_in(x = options, choices = names(formals(tar_option_set)))
33+
for (option in options) {
34+
tar_options[[option]] <- NULL
35+
}
36+
invisible()
37+
}

_pkgdown.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ reference:
3838
- 'tar_option_get'
3939
- 'tar_option_reset'
4040
- 'tar_option_set'
41+
- 'tar_option_unset'
4142
- 'tar_option_with'
4243
- title: Targets
4344
contents:

man/tar_config_get.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tar_config_projects.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tar_config_set.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tar_config_unset.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tar_config_yaml.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)