Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion cwltool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,13 @@ def generate_parser(toolparser, tool, namemap):
_logger.debug(u"Can't make command line argument from %s", inptype)
return None

if inptype != "boolean":
typekw = { 'type': atype }
else:
typekw = {}

toolparser.add_argument(flag + name, required=required,
help=ahelp, action=action, type=atype, default=default)
help=ahelp, action=action, default=default, **typekw)

return toolparser

Expand Down
27 changes: 27 additions & 0 deletions tests/test_toolargparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,37 @@ class ToolArgparse(unittest.TestCase):
glob: test.txt
stdout: test.txt
baseCommand: [cat]
'''

script2='''
#!/usr/bin/env cwl-runner
cwlVersion: 'cwl:draft-3'
class: CommandLineTool
inputs:
- id: bdg
type: "boolean"
outputs:
- id: output
type: File
outputBinding:
glob: foo
baseCommand:
- echo
- "ff"
stdout: foo
'''

def test_help(self):
with NamedTemporaryFile() as f:
f.write(self.script)
f.flush()
self.assertEquals(main([f.name, '--input', 'README.rst']), 0)

def test_bool(self):
with NamedTemporaryFile() as f:
f.write(self.script2)
f.flush()
try:
self.assertEquals(main([f.name, '--help']), 0)
except SystemExit as e:
self.assertEquals(e.code, 0)