From a3051ea306c0bf4057961d5194bc4a2b5d697f0a Mon Sep 17 00:00:00 2001 From: Michael Hipp Date: Thu, 4 Nov 2021 10:50:27 -0700 Subject: [PATCH 1/2] Allow closure for PublishDir.setMode --- .../src/main/groovy/nextflow/processor/PublishDir.groovy | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy index dabd1d37ee..55a0db2840 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy @@ -110,8 +110,12 @@ class PublishDir { this.path = obj.complete() } + void setMode( Closure obj ) { + setMode( obj.call() as String ) + } + void setMode( String str ) { - this.mode = str == 'copyNoFollow' ? Mode.COPY_NO_FOLLOW : str.toUpperCase() as Mode + this.mode = str.toUpperCase == 'COPYNOFOLLOW' ? Mode.COPY_NO_FOLLOW : str.toUpperCase() as Mode } void setMode( Mode mode ) { From 0d6795ab74e7fe2f995dd47d18ed92e91ca1e985 Mon Sep 17 00:00:00 2001 From: Michael Hipp Date: Thu, 4 Nov 2021 14:52:22 -0700 Subject: [PATCH 2/2] update enabled and overwrite to include closures --- .../nextflow/processor/PublishDir.groovy | 30 +++++++++++++++++-- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy index 55a0db2840..65638e1f81 100644 --- a/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/processor/PublishDir.groovy @@ -115,13 +115,37 @@ class PublishDir { } void setMode( String str ) { - this.mode = str.toUpperCase == 'COPYNOFOLLOW' ? Mode.COPY_NO_FOLLOW : str.toUpperCase() as Mode + this.mode = str.toUpperCase() == 'COPYNOFOLLOW' ? Mode.COPY_NO_FOLLOW : str.toUpperCase() as Mode } void setMode( Mode mode ) { this.mode = mode } + void setOverwrite( Closure obj ) { + setOverwrite( obj.call() as String ) + } + + void setOverwrite( String str ) { + setOverwrite( Boolean.parseBoolean( str ) ) + } + + void setOverwrite( Boolean bl ) { + this.overwrite = bl + } + + void setEnabled( Closure obj ) { + setEnabled( obj.call() as String ) + } + + void setEnabled( String str ) { + setEnabled( Boolean.parseBoolean( str ) ) + } + + void setEnabled( Boolean bl ) { + this.enabled = bl + } + @PackageScope boolean checkNull(String str) { ( str =~ /\bnull\b/ ).find() } @@ -151,13 +175,13 @@ class PublishDir { result.pattern = params.pattern if( params.overwrite != null ) - result.overwrite = Boolean.parseBoolean(params.overwrite.toString()) + result.overwrite = params.overwrite if( params.saveAs ) result.saveAs = params.saveAs if( params.enabled != null ) - result.enabled = Boolean.parseBoolean(params.enabled.toString()) + result.enabled = params.enabled return result }