mirror of https://github.com/ARMmbed/mbed-os.git
Rework the force types to match case
for example, argparse_force_uppercase_type will now correctly parse uARM to uARMpull/2010/head
parent
b4b514ea2f
commit
9040d27967
|
@ -229,14 +229,10 @@ def argparse_force_type(case):
|
|||
# arguments after converting it's case. Offer a suggestion if the hyphens/underscores
|
||||
# do not match the expected style of the argument.
|
||||
def parse_type(string):
|
||||
string = case(string)
|
||||
newstring = string.replace("-","_")
|
||||
if string in list:
|
||||
return string
|
||||
elif string not in list and newstring in list:
|
||||
raise argparse.ArgumentTypeError("{0} is not a supported {1}. Did you mean {2}?".format(string, type_name, newstring))
|
||||
else:
|
||||
raise argparse.ArgumentTypeError("{0} is not a supported {1}. Supported {1}s are:\n{2}".format(string, type_name, columnate(list)))
|
||||
for option in list:
|
||||
if case(string) == case(option):
|
||||
return option
|
||||
raise argparse.ArgumentTypeError("{0} is not a supported {1}. Supported {1}s are:\n{2}".format(string, type_name, columnate(list)))
|
||||
return parse_type
|
||||
return middle
|
||||
|
||||
|
|
Loading…
Reference in New Issue