@@ -68,13 +68,35 @@ def add_args_options(arg_parser, interface):
6868 args ["default" ] = getattr (inputs , name )
6969 args ["action" ] = 'store_true'
7070
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+
7181 if hasattr (spec , "mandatory" ) and spec .mandatory :
7282 if spec .is_trait_type (InputMultiPath ):
7383 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" ] = "+"
7490 arg_parser .add_argument (name , help = desc , ** args )
7591 else :
7692 if spec .is_trait_type (InputMultiPath ):
7793 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" ] = "*"
78100 arg_parser .add_argument ("--%s" % name , dest = name ,
79101 help = desc , ** args )
80102 return arg_parser
0 commit comments