Skip to content

Commit 26c1784

Browse files
authored
Merge branch '2.4.0dev' into add/debug-messages
2 parents 9bd7582 + 6bbe910 commit 26c1784

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1. Move the unpinned version check to an observer. This makes sure the warning is always shown and not only when importing a function.
1313
2. Added a missing inherited method to the observer to fix issues with workflow output publishing
1414
3. Fixed unexpected failures with samplesheet schemas using `anyOf`, `allOf` and `oneOf`
15+
4. Fixed an error with help messages when the `type` keyword was missing
1516

1617
## Improvements
1718

plugins/nf-schema/src/main/nextflow/validation/help/HelpMessageCreator.groovy

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,14 @@ class HelpMessageCreator {
172172
//
173173
private List<String> getHelpListParams(Map<String,Map> params, Integer maxChars, String parentParameter = "") {
174174
def List helpMessage = []
175-
def Integer typeMaxChars = longestStringLength(params.collect { key, value -> value.type instanceof String ? "[${value.type}]" : value.type as String})
175+
def Integer typeMaxChars = longestStringLength(params.collect { key, value ->
176+
def Object type = value.get("type", "")
177+
return type instanceof String && type.length() > 0 ? "[${type}]" : type as String}
178+
)
176179
for (String paramName in params.keySet()) {
177-
def Map paramOptions = params.get(paramName) as Map
178-
def String type = paramOptions.type instanceof String ? '[' + paramOptions.type + ']' : paramOptions.type as String
180+
def Map paramOptions = params.get(paramName) as Map
181+
def Object paramType = paramOptions.get("type", "")
182+
def String type = paramType instanceof String && paramType.length() > 0 ? '[' + paramType + ']' : paramType as String
179183
def String enumsString = ""
180184
if (paramOptions.enum != null) {
181185
def List enums = (List) paramOptions.enum

plugins/nf-schema/src/test/nextflow/validation/HelpMessageCreatorTest.groovy

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,4 +494,39 @@ Reference genome options
494494
assert resultHelp.size() == 0, "Found extra unexpected lines: ${resultHelp}"
495495
}
496496

497+
def 'should get a help message when missing the type keyword' () {
498+
given:
499+
def validationConfig = [
500+
monochromeLogs: true,
501+
parametersSchema: 'src/testResources/nextflow_schema_no_type.json',
502+
help: [
503+
enabled: true
504+
]
505+
]
506+
def params = [:]
507+
def config = new ValidationConfig(validationConfig, params)
508+
def helpCreator = new HelpMessageCreator(config, session)
509+
510+
when:
511+
def help = helpCreator.getShortMessage("") + helpCreator.getAfterText()
512+
513+
then:
514+
noExceptionThrown()
515+
def expectedHelp = """--input [string] Path to comma-separated file containing information about the samples in the experiment.
516+
--help [boolean, string] Show the help message for all top level parameters. When a parameter is given to `--help`, the full
517+
help message of that parameter will be printed.
518+
--helpFull [boolean] Show the help message for all non-hidden parameters.
519+
--showHidden [boolean] Show all hidden parameters in the help message. This needs to be used in combination with `--help`
520+
or `--helpFull`.
521+
522+
------------------------------------------------------
523+
524+
"""
525+
def resultHelp = help.readLines()
526+
expectedHelp.readLines().each {
527+
assert help.contains(it)
528+
resultHelp.removeElement(it)
529+
}
530+
assert resultHelp.size() == 0, "Found extra unexpected lines: ${resultHelp}"
531+
}
497532
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://raw.githubusercontent.com/nf-core/testpipeline/master/nextflow_schema.json",
4+
"title": "nf-core/testpipeline pipeline parameters",
5+
"description": "this is a test",
6+
"type": "object",
7+
"properties": {
8+
"input": {
9+
"type": "string",
10+
"format": "file-path",
11+
"mimetype": "text/csv",
12+
"pattern": "^\\S+\\.(csv|tsv|yaml|json)$",
13+
"description": "Path to comma-separated file containing information about the samples in the experiment.",
14+
"help_text": "You will need to create a design file with information about the samples in your experiment before running the pipeline. Use this parameter to specify its location. It has to be a comma-separated file with 3 columns, and a header row. See [usage docs](https://nf-co.re/testpipeline/usage#samplesheet-input).",
15+
"fa_icon": "fas fa-file-csv"
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)