@@ -68,13 +68,35 @@ def add_args_options(arg_parser, interface):
68
68
args ["default" ] = getattr (inputs , name )
69
69
args ["action" ] = 'store_true'
70
70
71
+ # current support is for simple trait types
72
+ if not spec .inner_traits :
73
+ trait_type = type (spec .trait_type .default_value )
74
+ if trait_type in (str , int , float ):
75
+ args ["type" ] = trait_type
76
+ elif len (spec .inner_traits ) == 1 :
77
+ trait_type = type (spec .inner_traits [0 ].trait_type .default_value )
78
+ if trait_type in (bool , str , int , float ):
79
+ args ["type" ] = trait_type
80
+
71
81
if hasattr (spec , "mandatory" ) and spec .mandatory :
72
82
if spec .is_trait_type (InputMultiPath ):
73
83
args ["nargs" ] = "+"
84
+ elif spec .is_trait_type (traits .List ):
85
+ if (spec .trait_type .minlen == spec .trait_type .maxlen ) and \
86
+ spec .trait_type .maxlen :
87
+ args ["nargs" ] = spec .trait_type .maxlen
88
+ else :
89
+ args ["nargs" ] = "+"
74
90
arg_parser .add_argument (name , help = desc , ** args )
75
91
else :
76
92
if spec .is_trait_type (InputMultiPath ):
77
93
args ["nargs" ] = "*"
94
+ elif spec .is_trait_type (traits .List ):
95
+ if (spec .trait_type .minlen == spec .trait_type .maxlen ) and \
96
+ spec .trait_type .maxlen :
97
+ args ["nargs" ] = spec .trait_type .maxlen
98
+ else :
99
+ args ["nargs" ] = "*"
78
100
arg_parser .add_argument ("--%s" % name , dest = name ,
79
101
help = desc , ** args )
80
102
return arg_parser
0 commit comments