-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathSummaryConfig.groovy
75 lines (63 loc) · 2.55 KB
/
SummaryConfig.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package nextflow.validation.config
import groovy.util.logging.Slf4j
import static nextflow.validation.utils.Colors.removeColors
import nextflow.config.schema.ConfigOption
import nextflow.config.schema.ConfigScope
import nextflow.config.schema.ScopeName
import nextflow.script.dsl.Description
/**
* This class allows to model a specific configuration, extracting values from a map and converting
*
* @author : nvnieuwk <[email protected]>
*
*/
@Slf4j
class SummaryConfig {
@ConfigOption
@Description('The text to show before the summary message.')
final public String beforeText = ""
@ConfigOption
@Description('The text to show after the summary message.')
final public String afterText = ""
@ConfigOption
@Description('A list of parameters to hide in the summary message.')
final public Set<String> hideParams = []
SummaryConfig(Map map, Boolean monochromeLogs) {
def config = map ?: Collections.emptyMap()
// beforeText
if(config.containsKey("beforeText")) {
if(config.beforeText instanceof String) {
if(monochromeLogs) {
beforeText = config.beforeText
} else {
beforeText = removeColors(config.beforeText)
}
log.debug("Set `validation.summary.beforeText` to ${beforeText}")
} else {
log.warn("Incorrect value detected for `validation.summary.beforeText`, a string is expected. Defaulting to `${beforeText}`")
}
}
// afterText
if(config.containsKey("afterText")) {
if(config.afterText instanceof String) {
if(monochromeLogs) {
afterText = config.afterText
} else {
afterText = removeColors(config.afterText)
}
log.debug("Set `validation.summary.afterText` to ${afterText}")
} else {
log.warn("Incorrect value detected for `validation.summary.afterText`, a string is expected. Defaulting to `${afterText}`")
}
}
// hideParams
if(config.containsKey("hideParams")) {
if(config.hideParams instanceof List<String>) {
hideParams = config.hideParams
log.debug("Set `validation.summary.hideParams` to ${hideParams}")
} else {
log.warn("Incorrect value detected for `validation.summary.hideParams`, a list of strings is expected. Defaulting to `${hideParams}`")
}
}
}
}