Skip to content

Commit a0c8a09

Browse files
committed
Unify look of argument errors
1 parent 862db41 commit a0c8a09

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

tools/get_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
if __name__ == '__main__':
3838
# Parse Options
3939
parser = get_default_options_parser(add_clean=False, add_options=False)
40-
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type,
40+
parser.add_argument("--source", dest="source_dir", type=argparse_filestring_type, required=True,
4141
default=[], help="The source (input) directory", action="append")
4242
parser.add_argument("--prefix", dest="prefix", action="append",
4343
default=[], help="Restrict listing to parameters that have this prefix")
@@ -48,12 +48,12 @@
4848

4949
# Target
5050
if options.mcu is None :
51-
args_error(parser, "[ERROR] You should specify an MCU")
51+
args_error(parser, "argument -m/--mcu is required")
5252
target = options.mcu[0]
5353

5454
# Toolchain
5555
if options.tool is None:
56-
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
56+
args_error(parser, "argument -t/--toolchain is required")
5757
toolchain = options.tool[0]
5858

5959
options.prefix = options.prefix or [""]

tools/make.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,12 @@
207207

208208
# Target
209209
if options.mcu is None :
210-
args_error(parser, "[ERROR] You should specify an MCU")
210+
args_error(parser, "argument -m/--mcu is required")
211211
mcu = options.mcu[0]
212212

213213
# Toolchain
214214
if options.tool is None:
215-
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
215+
args_error(parser, "argument -t/--toolchain is required")
216216
toolchain = options.tool[0]
217217

218218
if options.color:

tools/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@
107107

108108
# Target
109109
if options.mcu is None :
110-
args_error(parser, "[ERROR] You should specify an MCU")
110+
args_error(parser, "argument -m/--mcu is required")
111111
mcu = options.mcu[0]
112112

113113
# Toolchain
114114
if options.tool is None:
115-
args_error(parser, "[ERROR] You should specify a TOOLCHAIN")
115+
args_error(parser, "argument -t/--toolchain is required")
116116
toolchain = options.tool[0]
117117

118118
# Find all tests in the relevant paths

tools/utils.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,8 @@ def args_error(parser, message):
282282
parser - the ArgumentParser object that parsed the command line
283283
message - what went wrong
284284
"""
285-
print "\n\n%s\n\n" % message
286-
parser.print_help()
287-
sys.exit()
285+
parser.error(message)
286+
sys.exit(2)
288287

289288

290289
def construct_enum(**enums):

0 commit comments

Comments
 (0)