diff --git a/cwltool/argparser.py b/cwltool/argparser.py index f9d98e32d..efced5386 100644 --- a/cwltool/argparser.py +++ b/cwltool/argparser.py @@ -903,6 +903,11 @@ def add_argument( action = DirectoryAppendAction else: action = AppendAction + items = inptype["items"] + if items == "int" or items == "long": + atype = int + elif items == "double" or items == "float": + atype = float elif isinstance(inptype, MutableMapping) and inptype["type"] == "enum": atype = str elif isinstance(inptype, MutableMapping) and inptype["type"] == "record": diff --git a/tests/test_toolargparse.py b/tests/test_toolargparse.py index 756c373e8..11ce5e3db 100644 --- a/tests/test_toolargparse.py +++ b/tests/test_toolargparse.py @@ -101,6 +101,62 @@ outputs: [] """ +script_int = """ +#!/usr/bin/env cwl-runner + +cwlVersion: v1.0 +class: ExpressionTool + +inputs: + foo: int[] + +expression: '{"bar": $(inputs.foo)}' + +outputs: [] +""" + +script_long = """ +#!/usr/bin/env cwl-runner + +cwlVersion: v1.0 +class: ExpressionTool + +inputs: + foo: long[] + +expression: '{"bar": $(inputs.foo)}' + +outputs: [] +""" + +script_float = """ +#!/usr/bin/env cwl-runner + +cwlVersion: v1.0 +class: ExpressionTool + +inputs: + foo: float[] + +expression: '{"bar": $(inputs.foo)}' + +outputs: [] +""" + +script_double = """ +#!/usr/bin/env cwl-runner + +cwlVersion: v1.0 +class: ExpressionTool + +inputs: + foo: double[] + +expression: '{"bar": $(inputs.foo)}' + +outputs: [] +""" + scripts_argparse_params = [ ("help", script_a, lambda x: ["--debug", x, "--input", get_data("tests/echo.cwl")]), ("boolean", script_b, lambda x: [x, "--help"]), @@ -120,6 +176,31 @@ script_e, lambda x: [x, "--foo", "http://example.com"], ), + ( + "foo with int", + script_int, + lambda x: [x, "--foo", "1", "--foo", "2"], + ), + ( + "foo with long for large value", + script_long, + lambda x: [x, "--foo", str(2**31 + 10)], + ), + ( + "foo with long for small value", + script_long, + lambda x: [x, "--foo", str(-1 * (2**31) - 10)], + ), + ( + "foo with float", + script_float, + lambda x: [x, "--foo", "1.2", "--foo", "3.4"], + ), + ( + "foo with double", + script_double, + lambda x: [x, "--foo", "1.2", "--foo", "3.4"], + ), ]