Skip to content

Commit 01ff76c

Browse files
author
MaxUlysse
committed
update nextflow version requested and enhance messages
1 parent 067311f commit 01ff76c

File tree

1 file changed

+78
-56
lines changed

1 file changed

+78
-56
lines changed

main.nf

Lines changed: 78 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ vim: syntax=groovy
77
= C O M P I L E - B E A M E R =
88
================================================================================
99
@Author
10-
Maxime Garcia <max@ithake.eu> [@MaxUlysse]
10+
Maxime Garcia <max[email protected]> [@MaxUlysse]
1111
--------------------------------------------------------------------------------
1212
@Homepage
1313
https://github.com/MaxUlysse/compile-beamer
@@ -25,24 +25,26 @@ Maxime Garcia <[email protected]> [@MaxUlysse]
2525
================================================================================
2626
*/
2727

28+
if (!nextflow.version.matches('>= 0.25.0')) {exit 1, "Nextflow version 0.25.0 or greater is needed to run this workflow"}
29+
2830
version = '1.5'
2931

3032
switch (params) {
31-
case {params.help} :
32-
helpMessage(version, grabRevision())
33-
exit 1
33+
case {params.help} :
34+
helpMessage()
35+
exit 1
3436

35-
case {params.version} :
36-
versionMessage(version, grabRevision())
37-
exit 1
37+
case {params.version} :
38+
versionMessage()
39+
exit 1
3840
}
3941

4042
if (!params.tex) {exit 1, 'No tex file, see --help for more information'}
4143

4244
pictures = file(params.pictures)
4345
tex = file(params.tex)
4446

45-
startMessage(version, grabRevision())
47+
startMessage()
4648

4749
/*
4850
================================================================================
@@ -51,22 +53,22 @@ startMessage(version, grabRevision())
5153
*/
5254

5355
process RunXelatex {
54-
tag {tex}
56+
tag {tex}
5557

56-
publishDir ".", mode: 'move'
58+
publishDir ".", mode: 'move'
5759

58-
input:
59-
file tex
60-
file pictures
60+
input:
61+
file tex
62+
file pictures
6163

62-
output:
63-
file("${tex.baseName}.pdf") into pdf
64+
output:
65+
file("${tex.baseName}.pdf") into pdf
6466

65-
script:
66-
"""
67-
xelatex -shell-escape ${tex.baseName}
68-
xelatex -shell-escape ${tex.baseName}
69-
"""
67+
script:
68+
"""
69+
xelatex -shell-escape ${tex.baseName}
70+
xelatex -shell-escape ${tex.baseName}
71+
"""
7072
}
7173

7274
/*
@@ -75,53 +77,73 @@ process RunXelatex {
7577
================================================================================
7678
*/
7779

80+
def compileBeamerMessage() {
81+
// Display COMPILE-BEAMER message
82+
log.info "COMPILE-BEAMER ~ $version - " + this.grabRevision() + (workflow.commitId ? " [$workflow.commitId]" : "")
83+
}
84+
85+
7886
def grabRevision() {
79-
return workflow.revision ?: workflow.scriptId.substring(0,10)
87+
// Return the same string executed from github or not
88+
return workflow.revision ?: workflow.commitId ?: workflow.scriptId.substring(0,10)
89+
}
90+
91+
def helpMessage() {
92+
// Display help message
93+
this.compileBeamerMessage()
94+
log.info " Usage:"
95+
log.info " nextflow run MaxUlysse/compile-beamer --tex <input.tex> --theme <BTB||KI||SciLifeLab>"
96+
log.info " --tex"
97+
log.info " Compile the given tex file"
98+
log.info " --help"
99+
log.info " you're reading it"
100+
log.info " --version"
101+
log.info " displays version number"
102+
}
103+
104+
def minimalInformationMessage() {
105+
// Minimal information message
106+
log.info "Command Line: $workflow.commandLine"
107+
log.info "Project Dir : $workflow.projectDir"
108+
log.info "Launch Dir : $workflow.launchDir"
109+
log.info "Work Dir : $workflow.workDir"
110+
log.info "Tex file : $tex"
111+
log.info "Pictures in : $pictures"
80112
}
81113

82-
def helpMessage(version, revision) {
83-
log.info "COMPILE-BEAMER ~ $version - revision: $revision"
84-
log.info " Usage:"
85-
log.info " nextflow run MaxUlysse/compile-beamer --tex <input.tex> --theme <BTB||KI||SciLifeLab>"
86-
log.info " --tex"
87-
log.info " Compile the given tex file"
88-
log.info " --help"
89-
log.info " you're reading it"
90-
log.info " --version"
91-
log.info " displays version number"
114+
def nextflowMessage() {
115+
// Nextflow message (version + build)
116+
log.info "N E X T F L O W ~ version $workflow.nextflow.version $workflow.nextflow.build"
92117
}
93118

94-
def startMessage(version, revision) {
95-
log.info "COMPILE-BEAMER ~ $version - revision: $revision"
96-
log.info "Command line: $workflow.commandLine"
97-
log.info "Project Dir : $workflow.projectDir"
98-
log.info "Launch Dir : $workflow.launchDir"
99-
log.info "Work Dir : $workflow.workDir"
119+
def startMessage() {
120+
// Display start message
121+
this.compileBeamerMessage()
122+
this.minimalInformationMessage()
100123
}
101124

102-
def versionMessage(version, revision) {
103-
log.info "COMPILE-BEAMER"
104-
log.info " version $version"
105-
log.info ((workflow.commitId) ? "Git info : $workflow.repository - $workflow.revision [$workflow.commitId]" : " revision: $revision")
106-
log.info "Project : $workflow.projectDir"
107-
log.info "Directory: $workflow.launchDir"
125+
def versionMessage() {
126+
// Display version message
127+
log.info "COMPILE-BEAMER"
128+
log.info " version $version"
129+
log.info workflow.commitId ? "Git info : $workflow.repository - $workflow.revision [$workflow.commitId]" : " revision : " + this.grabRevision()
108130
}
109131

110132
workflow.onComplete {
111-
log.info "N E X T F L O W ~ $workflow.nextflow.version - $workflow.nextflow.build"
112-
log.info "COMPILE-BEAMER ~ $version - revision: $revision"
113-
log.info "Command line: $workflow.commandLine"
114-
log.info "Project Dir : $workflow.projectDir"
115-
log.info "Launch Dir : $workflow.launchDir"
116-
log.info "Work Dir : $workflow.workDir"
117-
log.info "Completed at: $workflow.complete"
118-
log.info "Duration : $workflow.duration"
119-
log.info "Success : $workflow.success"
120-
log.info "Exit status : $workflow.exitStatus"
121-
log.info "Error report:" + (workflow.errorReport ?: '-')
133+
// Display end message
134+
this.nextflowMessage()
135+
this.compileBeamerMessage()
136+
this.minimalInformationMessage()
137+
log.info "Completed at: $workflow.complete"
138+
log.info "Duration : $workflow.duration"
139+
log.info "Success : $workflow.success"
140+
log.info "Exit status : $workflow.exitStatus"
141+
log.info "Error report:" + (workflow.errorReport ?: '-')
122142
}
123143

124144
workflow.onError {
125-
log.info "COMPILE-BEAMER"
126-
log.info "Workflow execution stopped with the following message: $workflow.errorMessage"
145+
// Display error message
146+
this.nextflowMessage()
147+
this.compileBeamerMessage()
148+
log.info "Workflow execution stopped with the following message: $workflow.errorMessage"
127149
}

0 commit comments

Comments
 (0)