6
6
# ' `directory_*()` functions allow users to interface with the directory,
7
7
# ' making new "chores" available:
8
8
# '
9
- # ' * `directory_path()` returns the path to the prompt directory, which
10
- # ' defaults to `~/.config/chores`.
9
+ # ' * `directory_path()` returns the path to the prompt directory.
11
10
# ' * `directory_set()` changes the path to the prompt directory (by setting
12
11
# ' the option `.chores_dir`).
13
12
# ' * `directory_list()` enumerates all of the different prompts that currently
14
13
# ' live in the directory (and provides clickable links to each).
15
14
# ' * `directory_load()` registers each of the prompts in the prompt
16
- # ' directory with the chores package (via [.helper_add()]) .
15
+ # ' directory with the chores package.
17
16
# '
18
17
# ' [Functions prefixed with][prompt] `prompt*()` allow users to conveniently create, edit,
19
18
# ' and delete the prompts in chores' prompt directory.
51
50
# ' loading the package, just set the `.chores_dir` option with
52
51
# ' `options(.chores_dir = some_dir)`. To load a directory of files that's not
53
52
# ' the prompt directory, provide a `dir` argument to `directory_load()`.
53
+ # '
54
+ # ' @returns
55
+ # ' * `directory_path()` returns the path to the prompt directory (which is
56
+ # ' not created by default unless explicitly requested by the user).
57
+ # ' * `directory_set()` return the path to the new prompt directory.
58
+ # ' * `directory_list()` returns the file paths of all of the prompts that
59
+ # ' currently live in the directory (and provides clickable links to each).
60
+ # ' * `directory_load()` returns `NULL` invisibly.
61
+ # '
54
62
# ' @name directory
55
63
# '
56
- # ' @seealso The "Custom helpers" vignette, at `vignette("custom", package = "chores")`,
57
- # ' for more on adding your own helper prompts, sharing them with others, and
58
- # ' using prompts from others.
64
+ # ' @seealso The "Custom helpers" vignette, at
65
+ # ' `vignette("custom", package = "chores")`,for more on adding your own
66
+ # ' helper prompts, sharing them with others, and using prompts from others.
67
+ # '
68
+ # ' @examples
69
+ # ' # choose a path for the prompt directory
70
+ # ' tmp_dir <- withr::local_tempdir()
71
+ # ' directory_set(tmp_dir)
59
72
# '
60
- # ' @examplesIf FALSE
61
73
# ' # print out the current prompt directory
62
- # ' directory_get ()
74
+ # ' directory_path ()
63
75
# '
64
76
# ' # list out prompts currently in the directory
65
77
# ' directory_list()
74
86
# ' # (this will also happen automatically on reload)
75
87
# ' directory_load()
76
88
# '
77
- # ' # these are equivalent:
78
- # ' directory_set("some/folder")
79
- # ' options(.chores_dir = "some/folder")
80
- # '
81
89
# ' @export
82
90
directory_load <- function (dir = directory_path()) {
83
91
prompt_base_names <- directory_base_names(dir )
@@ -94,6 +102,8 @@ directory_load <- function(dir = directory_path()) {
94
102
95
103
.helper_add(chore = chore , prompt = prompt , interface = interface )
96
104
}
105
+
106
+ invisible ()
97
107
}
98
108
99
109
# ' @rdname directory
@@ -131,7 +141,17 @@ directory_list <- function() {
131
141
# ' @rdname directory
132
142
# ' @export
133
143
directory_path <- function () {
134
- getOption(" .chores_dir" , default = file.path(" ~" , " .config" , " chores" ))
144
+ .chores_dir <- getOption(" .chores_dir" , default = NULL )
145
+
146
+ if (is.null(.chores_dir )) {
147
+ cli :: cli_warn(c(
148
+ " No {.pkg chores} prompt directory configured." ,
149
+ ' Set one in your {.file .Rprofile} using e.g.
150
+ {.code directory_set(file.path("~", ".config", "chores"))}.'
151
+ ))
152
+ }
153
+
154
+ .chores_dir
135
155
}
136
156
137
157
# ' @rdname directory
0 commit comments