@@ -146,6 +146,10 @@ def capabilities(cls):
146
146
147
147
@classmethod
148
148
def do_add_parser (cls , parser ):
149
+ # To accept arguments in hex format, a wrapper lambda around int() must be used.
150
+ # Wrapping the lambda with functools.wraps() makes it so that 'invalid int value'
151
+ # is displayed when an invalid value is provided for these arguments.
152
+ multi_base = functools .wraps (int )(lambda s : int (s , base = 0 ))
149
153
parser .add_argument (
150
154
"--port" ,
151
155
type = str ,
@@ -164,12 +168,9 @@ def do_add_parser(cls, parser):
164
168
)
165
169
parser .add_argument (
166
170
"--download-address" ,
167
- # To accept arguments in hex format, a wrapper lambda around int() must be used.
168
- # Wrapping the lambda with functools.wraps() makes it so that 'invalid int value'
169
- # is displayed when an invalid value is provided for this argument.
170
- type = functools .wraps (int )(lambda s : int (s , base = 0 )),
171
+ type = multi_base ,
171
172
required = False ,
172
- help = "Flashing location address. To be used only with .bin files "
173
+ help = "Flashing location address. If present, .bin used instead of .hex "
173
174
)
174
175
parser .add_argument (
175
176
"--download-modifiers" ,
@@ -180,10 +181,7 @@ def do_add_parser(cls, parser):
180
181
)
181
182
parser .add_argument (
182
183
"--start-address" ,
183
- # To accept arguments in hex format, a wrapper lambda around int() must be used.
184
- # Wrapping the lambda with functools.wraps() makes it so that 'invalid int value'
185
- # is displayed when an invalid value is provided for this argument.
186
- type = functools .wraps (int )(lambda s : int (s , base = 0 )),
184
+ type = multi_base ,
187
185
required = False ,
188
186
help = "Address where execution should begin after flashing"
189
187
)
0 commit comments