Skip to content

Commit cbfed3e

Browse files
committed
split source file into multiple psrts
1 parent d6c1b38 commit cbfed3e

File tree

2 files changed

+43
-44
lines changed

2 files changed

+43
-44
lines changed

R/context/get_config.R

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#' get user parameter value inside current workflow context environment
2+
#'
3+
#' @param name a character vector of the parameter name
4+
#' @param default the default value for the parameter if missing from the
5+
#' workflow context environment.
6+
#'
7+
#' @return the parameter value, maybe is object value in character type,
8+
#' a type cast function expression invoke example as:
9+
#' ``as.logical``, ``as.double``, etc maybe required.
10+
#'
11+
const get_config = function(name, default = NULL, warn_msg = NULL) {
12+
const path = strsplit(name, "$", fixed = TRUE);
13+
const verbose = as.logical(getOption("verbose"));
14+
15+
if (verbose) {
16+
if (length(path) > 1) {
17+
print(`get configuration from path: ${paste(path, sep = " -> ")}`);
18+
} else {
19+
print(`get configuation via a key: ${name}`);
20+
}
21+
}
22+
23+
let config = pull_configs();
24+
25+
for(name in path) {
26+
if (name in config) {
27+
config = config[[name]];
28+
} else {
29+
return(default);
30+
}
31+
}
32+
33+
if (is.null(warn_msg)) {
34+
return(config || default);
35+
} else {
36+
if (is.null(config)) {
37+
echo_warning(warn_msg);
38+
default;
39+
} else {
40+
config;
41+
}
42+
}
43+
}

R/context/set_config.R

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,6 @@ const set_config = function(configs = list()) {
2828
invisible(NULL);
2929
}
3030

31-
#' get user parameter value inside current workflow context environment
32-
#'
33-
#' @param name a character vector of the parameter name
34-
#' @param default the default value for the parameter if missing from the
35-
#' workflow context environment.
36-
#'
37-
#' @return the parameter value, maybe is object value in character type,
38-
#' a type cast function expression invoke example as:
39-
#' ``as.logical``, ``as.double``, etc maybe required.
40-
#'
41-
const get_config = function(name, default = NULL, warn_msg = NULL) {
42-
const path = strsplit(name, "$", fixed = TRUE);
43-
const verbose = as.logical(getOption("verbose"));
44-
45-
if (verbose) {
46-
if (length(path) > 1) {
47-
print(`get configuration from path: ${paste(path, sep = " -> ")}`);
48-
} else {
49-
print(`get configuation via a key: ${name}`);
50-
}
51-
}
52-
53-
let config = pull_configs();
54-
55-
for(name in path) {
56-
if (name in config) {
57-
config = config[[name]];
58-
} else {
59-
return(default);
60-
}
61-
}
62-
63-
if (is.null(warn_msg)) {
64-
return(config || default);
65-
} else {
66-
if (is.null(config)) {
67-
echo_warning(warn_msg);
68-
default;
69-
} else {
70-
config;
71-
}
72-
}
73-
}
74-
7531
#' pull all configuration value from workflow registry
7632
#'
7733
const pull_configs = function() {

0 commit comments

Comments
 (0)