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
|
# arguments after converting it's case. Offer a suggestion if the hyphens/underscores
|
||||||
# do not match the expected style of the argument.
|
# do not match the expected style of the argument.
|
||||||
def parse_type(string):
|
def parse_type(string):
|
||||||
string = case(string)
|
for option in list:
|
||||||
newstring = string.replace("-","_")
|
if case(string) == case(option):
|
||||||
if string in list:
|
return option
|
||||||
return string
|
raise argparse.ArgumentTypeError("{0} is not a supported {1}. Supported {1}s are:\n{2}".format(string, type_name, columnate(list)))
|
||||||
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)))
|
|
||||||
return parse_type
|
return parse_type
|
||||||
return middle
|
return middle
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue