mirror of https://github.com/ARMmbed/mbed-os.git
Unify look of argument errors
parent
862db41be3
commit
a0c8a09c89
|
@ -37,7 +37,7 @@ except:
|
|||
if __name__ == '__main__':
|
||||
# Parse Options
|
||||
parser = get_default_options_parser(add_clean=False, add_options=False)
|
||||
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type,
|
||||
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, required=True,
|
||||
default=[], help="The source (input) directory", action="append")
|
||||
parser.add_argument("--prefix", dest="prefix", action="append",
|
||||
default=[], help="Restrict listing to parameters that have this prefix")
|
||||
|
@ -48,12 +48,12 @@ if __name__ == '__main__':
|
|||
|
||||
# Target
|
||||
if options.mcu is None :
|
||||
args_error(parser, "[ERROR] You should specify an MCU")
|
||||
args_error(parser, "argument -m/--mcu is required")
|
||||
target = options.mcu[0]
|
||||
|
||||
# Toolchain
|
||||
if options.tool is None:
|
||||
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
|
||||
args_error(parser, "argument -t/--toolchain is required")
|
||||
toolchain = options.tool[0]
|
||||
|
||||
options.prefix = options.prefix or [""]
|
||||
|
|
|
@ -207,12 +207,12 @@ if __name__ == '__main__':
|
|||
|
||||
# Target
|
||||
if options.mcu is None :
|
||||
args_error(parser, "[ERROR] You should specify an MCU")
|
||||
args_error(parser, "argument -m/--mcu is required")
|
||||
mcu = options.mcu[0]
|
||||
|
||||
# Toolchain
|
||||
if options.tool is None:
|
||||
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
|
||||
args_error(parser, "argument -t/--toolchain is required")
|
||||
toolchain = options.tool[0]
|
||||
|
||||
if options.color:
|
||||
|
|
|
@ -107,12 +107,12 @@ if __name__ == '__main__':
|
|||
|
||||
# Target
|
||||
if options.mcu is None :
|
||||
args_error(parser, "[ERROR] You should specify an MCU")
|
||||
args_error(parser, "argument -m/--mcu is required")
|
||||
mcu = options.mcu[0]
|
||||
|
||||
# Toolchain
|
||||
if options.tool is None:
|
||||
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
|
||||
args_error(parser, "argument -t/--toolchain is required")
|
||||
toolchain = options.tool[0]
|
||||
|
||||
# Find all tests in the relevant paths
|
||||
|
|
|
@ -282,9 +282,8 @@ def args_error(parser, message):
|
|||
parser - the ArgumentParser object that parsed the command line
|
||||
message - what went wrong
|
||||
"""
|
||||
print "\n\n%s\n\n" % message
|
||||
parser.print_help()
|
||||
sys.exit()
|
||||
parser.error(message)
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def construct_enum(**enums):
|
||||
|
|
Loading…
Reference in New Issue