@@ -371,14 +371,17 @@ def capital(self):
371371 )
372372
373373
374- int_re = re .compile ("(int(eger)?)|size|length|max|min" , flags = re .IGNORECASE )
374+ int_re = re .compile ("(int(eger)?)|size|length|max|min|num(ber)? " , flags = re .IGNORECASE )
375375str_re = re .compile ("str(ing)?" , flags = re .IGNORECASE )
376376float_re = re .compile ("float|decimal" , flags = re .IGNORECASE )
377377bool_re = re .compile ("bool(ean)?" , flags = re .IGNORECASE )
378378file_re = re .compile ("file|path" , flags = re .IGNORECASE )
379379dir_re = re .compile ("folder|directory" , flags = re .IGNORECASE )
380380
381381default_re = re .compile ("default(?: value)?(?:[:=] ?| )([^ )\]]+)" , flags = re .IGNORECASE )
382+ float_re = re .compile ('[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)' , flags = re .IGNORECASE )
383+ int_re = re .compile ('[+-]?([0-9]+[^.0-9])' , flags = re .IGNORECASE )
384+
382385
383386def infer_type (string ) -> typing .Optional [cli_types .CliType ]:
384387 """
@@ -403,6 +406,10 @@ def infer_type(string) -> typing.Optional[cli_types.CliType]:
403406 return cli_types .CliDir (default = default )
404407 elif str_re .match (string ):
405408 return cli_types .CliString (default = default )
409+ elif float_re .search (string ) and not int_re .search (string ):
410+ return cli_types .CliFloat (default = default )
411+ elif not int_re .search (string ) and int_re .search (string ):
412+ return cli_types .CliInteger (default = default )
406413 else :
407414 return cli_types .CliString (default = default )
408415
0 commit comments