Skip to content

Commit e759783

Browse files
committed
Error messages: Fix ANSI colours
1 parent d96f6de commit e759783

4 files changed

Lines changed: 21 additions & 2 deletions

File tree

modules/nextflow/src/main/groovy/nextflow/config/ConfigBuilder.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,12 @@ class ConfigBuilder {
366366
assert env != null
367367

368368
final ignoreIncludes = options ? options.ignoreConfigIncludes : false
369+
final ansiLog = options ? options.ansiLog : false
369370
final parser = ConfigParserFactory.create()
370371
.setRenderClosureAsString(showClosures)
371372
.setStripSecrets(stripSecrets)
372373
.setIgnoreIncludes(ignoreIncludes)
374+
.setAnsiLog(ansiLog)
373375
ConfigObject result = new ConfigObject()
374376

375377
if( cliParams )

modules/nextflow/src/main/groovy/nextflow/config/ConfigParser.groovy

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ interface ConfigParser {
7272
*/
7373
ConfigParser setProfiles(List<String> profiles)
7474

75+
/**
76+
* Toggle whether to render compilation errors with ANSI colors.
77+
*
78+
* @param value
79+
*/
80+
default ConfigParser setAnsiLog(boolean value) {
81+
return this
82+
}
83+
7584
/**
7685
* Parse a config object from the given source.
7786
*/

modules/nextflow/src/main/groovy/nextflow/config/parser/v2/ConfigParserV2.groovy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class ConfigParserV2 implements ConfigParser {
4949

5050
private boolean stripSecrets
5151

52+
private boolean ansiLog
53+
5254
private List<String> appliedProfiles
5355

5456
private Set<String> declaredProfiles = []
@@ -87,6 +89,12 @@ class ConfigParserV2 implements ConfigParser {
8789
return this
8890
}
8991

92+
@Override
93+
ConfigParserV2 setAnsiLog(boolean value) {
94+
this.ansiLog = value
95+
return this
96+
}
97+
9098
@Override
9199
ConfigParserV2 setBinding(Map vars) {
92100
this.bindingVars = vars
@@ -157,7 +165,7 @@ class ConfigParserV2 implements ConfigParser {
157165

158166
private void printErrors(Path path) {
159167
final source = compiler.getSource()
160-
final errorListener = new StandardErrorListener('full', false)
168+
final errorListener = new StandardErrorListener('full', ansiLog)
161169
println()
162170
errorListener.beforeErrors()
163171
for( final message : compiler.getErrors() ) {

modules/nextflow/src/main/groovy/nextflow/script/parser/v2/ScriptLoaderV2.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class ScriptLoaderV2 implements ScriptLoader {
131131
}
132132

133133
private void printErrors(Path path) {
134-
final errorListener = new StandardErrorListener('full', false)
134+
final errorListener = new StandardErrorListener('full', session.ansiLog)
135135
println()
136136
errorListener.beforeErrors()
137137
for( final message : compiler.getErrors() ) {

0 commit comments

Comments
 (0)