Skip to content

Commit 6b3c2dc

Browse files
committed
support custom records on the command line
1 parent 0cadfc7 commit 6b3c2dc

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

cwltool/main.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ def add_argument(toolparser, name, inptype, description="", default=None):
328328
action = "append"
329329
elif isinstance(inptype, dict) and inptype["type"] == "enum":
330330
atype = Text
331+
elif isinstance(inptype, dict) and inptype["type"] == "record":
332+
for field in inptype['fields']:
333+
fieldname = name+"."+shortname(field['name'])
334+
fieldtype = field['type']
335+
fielddescription = field.get("doc", "")
336+
add_argument(
337+
toolparser, fieldname, fieldtype, fielddescription)
338+
return
331339
if inptype == "string":
332340
atype = Text
333341
elif inptype == "int":

tests/test_toolargparse.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,23 @@ class ToolArgparse(unittest.TestCase):
4242
- echo
4343
- "ff"
4444
stdout: foo
45+
'''
46+
47+
script3='''
48+
#!/usr/bin/env cwl-runner
49+
50+
cwlVersion: v1.0
51+
class: ExpressionTool
52+
53+
inputs:
54+
foo:
55+
type:
56+
type: record
57+
fields:
58+
one: File
59+
two: string
60+
61+
outputs: []
4562
'''
4663

4764
def test_help(self):
@@ -59,3 +76,16 @@ def test_bool(self):
5976
self.assertEquals(main([f.name, '--help']), 0)
6077
except SystemExit as e:
6178
self.assertEquals(e.code, 0)
79+
80+
def test_record(self):
81+
with NamedTemporaryFile() as f:
82+
f.write(self.script3)
83+
f.flush()
84+
try:
85+
self.assertEquals(main([f.name, '--help']), 0)
86+
except SystemExit as e:
87+
self.assertEquals(e.code, 0)
88+
89+
90+
if __name__ == '__main__':
91+
unittest.main()

0 commit comments

Comments
 (0)