Skip to content

Commit

Permalink
update nextflow version requested and enhance messages
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxUlysse committed Jun 28, 2017
1 parent 067311f commit 01ff76c
Showing 1 changed file with 78 additions and 56 deletions.
134 changes: 78 additions & 56 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ vim: syntax=groovy
= C O M P I L E - B E A M E R =
================================================================================
@Author
Maxime Garcia <max@ithake.eu> [@MaxUlysse]
Maxime Garcia <max[email protected]> [@MaxUlysse]
--------------------------------------------------------------------------------
@Homepage
https://github.com/MaxUlysse/compile-beamer
Expand All @@ -25,24 +25,26 @@ Maxime Garcia <[email protected]> [@MaxUlysse]
================================================================================
*/

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

version = '1.5'

switch (params) {
case {params.help} :
helpMessage(version, grabRevision())
exit 1
case {params.help} :
helpMessage()
exit 1

case {params.version} :
versionMessage(version, grabRevision())
exit 1
case {params.version} :
versionMessage()
exit 1
}

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

pictures = file(params.pictures)
tex = file(params.tex)

startMessage(version, grabRevision())
startMessage()

/*
================================================================================
Expand All @@ -51,22 +53,22 @@ startMessage(version, grabRevision())
*/

process RunXelatex {
tag {tex}
tag {tex}

publishDir ".", mode: 'move'
publishDir ".", mode: 'move'

input:
file tex
file pictures
input:
file tex
file pictures

output:
file("${tex.baseName}.pdf") into pdf
output:
file("${tex.baseName}.pdf") into pdf

script:
"""
xelatex -shell-escape ${tex.baseName}
xelatex -shell-escape ${tex.baseName}
"""
script:
"""
xelatex -shell-escape ${tex.baseName}
xelatex -shell-escape ${tex.baseName}
"""
}

/*
Expand All @@ -75,53 +77,73 @@ process RunXelatex {
================================================================================
*/

def compileBeamerMessage() {
// Display COMPILE-BEAMER message
log.info "COMPILE-BEAMER ~ $version - " + this.grabRevision() + (workflow.commitId ? " [$workflow.commitId]" : "")
}


def grabRevision() {
return workflow.revision ?: workflow.scriptId.substring(0,10)
// Return the same string executed from github or not
return workflow.revision ?: workflow.commitId ?: workflow.scriptId.substring(0,10)
}

def helpMessage() {
// Display help message
this.compileBeamerMessage()
log.info " Usage:"
log.info " nextflow run MaxUlysse/compile-beamer --tex <input.tex> --theme <BTB||KI||SciLifeLab>"
log.info " --tex"
log.info " Compile the given tex file"
log.info " --help"
log.info " you're reading it"
log.info " --version"
log.info " displays version number"
}

def minimalInformationMessage() {
// Minimal information message
log.info "Command Line: $workflow.commandLine"
log.info "Project Dir : $workflow.projectDir"
log.info "Launch Dir : $workflow.launchDir"
log.info "Work Dir : $workflow.workDir"
log.info "Tex file : $tex"
log.info "Pictures in : $pictures"
}

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

def startMessage(version, revision) {
log.info "COMPILE-BEAMER ~ $version - revision: $revision"
log.info "Command line: $workflow.commandLine"
log.info "Project Dir : $workflow.projectDir"
log.info "Launch Dir : $workflow.launchDir"
log.info "Work Dir : $workflow.workDir"
def startMessage() {
// Display start message
this.compileBeamerMessage()
this.minimalInformationMessage()
}

def versionMessage(version, revision) {
log.info "COMPILE-BEAMER"
log.info " version $version"
log.info ((workflow.commitId) ? "Git info : $workflow.repository - $workflow.revision [$workflow.commitId]" : " revision: $revision")
log.info "Project : $workflow.projectDir"
log.info "Directory: $workflow.launchDir"
def versionMessage() {
// Display version message
log.info "COMPILE-BEAMER"
log.info " version $version"
log.info workflow.commitId ? "Git info : $workflow.repository - $workflow.revision [$workflow.commitId]" : " revision : " + this.grabRevision()
}

workflow.onComplete {
log.info "N E X T F L O W ~ $workflow.nextflow.version - $workflow.nextflow.build"
log.info "COMPILE-BEAMER ~ $version - revision: $revision"
log.info "Command line: $workflow.commandLine"
log.info "Project Dir : $workflow.projectDir"
log.info "Launch Dir : $workflow.launchDir"
log.info "Work Dir : $workflow.workDir"
log.info "Completed at: $workflow.complete"
log.info "Duration : $workflow.duration"
log.info "Success : $workflow.success"
log.info "Exit status : $workflow.exitStatus"
log.info "Error report:" + (workflow.errorReport ?: '-')
// Display end message
this.nextflowMessage()
this.compileBeamerMessage()
this.minimalInformationMessage()
log.info "Completed at: $workflow.complete"
log.info "Duration : $workflow.duration"
log.info "Success : $workflow.success"
log.info "Exit status : $workflow.exitStatus"
log.info "Error report:" + (workflow.errorReport ?: '-')
}

workflow.onError {
log.info "COMPILE-BEAMER"
log.info "Workflow execution stopped with the following message: $workflow.errorMessage"
// Display error message
this.nextflowMessage()
this.compileBeamerMessage()
log.info "Workflow execution stopped with the following message: $workflow.errorMessage"
}

0 comments on commit 01ff76c

Please sign in to comment.