File tree Expand file tree Collapse file tree 1 file changed +24
-40
lines changed
interpreter/terminal_interface Expand file tree Collapse file tree 1 file changed +24
-40
lines changed Original file line number Diff line number Diff line change @@ -252,56 +252,40 @@ def start_terminal_interface(interpreter):
252
252
sys .argv .remove (old_flag )
253
253
sys .argv .append (new_flag )
254
254
255
- parser = argparse .ArgumentParser (description = "Open Interpreter" )
255
+ parser = argparse .ArgumentParser (
256
+ description = "Open Interpreter" , usage = "%(prog)s [options]"
257
+ )
256
258
257
259
# Add arguments
258
260
for arg in arguments :
259
261
action = arg .get ("action" , "store_true" )
260
262
nickname = arg .get ("nickname" )
261
263
default = arg .get ("default" )
262
264
265
+ # Construct argument name flags
266
+ flags = (
267
+ [f"-{ nickname } " , f'--{ arg ["name" ]} ' ] if nickname else [f'--{ arg ["name" ]} ' ]
268
+ )
269
+
263
270
if arg ["type" ] == bool :
264
- if nickname :
265
- parser .add_argument (
266
- f"-{ nickname } " ,
267
- f'--{ arg ["name" ]} ' ,
268
- dest = arg ["name" ],
269
- help = arg ["help_text" ],
270
- action = action ,
271
- default = default ,
272
- )
273
- else :
274
- parser .add_argument (
275
- f'--{ arg ["name" ]} ' ,
276
- dest = arg ["name" ],
277
- help = arg ["help_text" ],
278
- action = action ,
279
- default = default ,
280
- )
271
+ parser .add_argument (
272
+ * flags ,
273
+ dest = arg ["name" ],
274
+ help = arg ["help_text" ],
275
+ action = action ,
276
+ default = default ,
277
+ )
281
278
else :
282
279
choices = arg .get ("choices" )
283
-
284
- if nickname :
285
- parser .add_argument (
286
- f"-{ nickname } " ,
287
- f'--{ arg ["name" ]} ' ,
288
- dest = arg ["name" ],
289
- help = arg ["help_text" ],
290
- type = arg ["type" ],
291
- choices = choices ,
292
- default = default ,
293
- nargs = arg .get ("nargs" ),
294
- )
295
- else :
296
- parser .add_argument (
297
- f'--{ arg ["name" ]} ' ,
298
- dest = arg ["name" ],
299
- help = arg ["help_text" ],
300
- type = arg ["type" ],
301
- choices = choices ,
302
- default = default ,
303
- nargs = arg .get ("nargs" ),
304
- )
280
+ parser .add_argument (
281
+ * flags ,
282
+ dest = arg ["name" ],
283
+ help = arg ["help_text" ],
284
+ type = arg ["type" ],
285
+ choices = choices ,
286
+ default = default ,
287
+ nargs = arg .get ("nargs" ),
288
+ )
305
289
306
290
args , unknown_args = parser .parse_known_args ()
307
291
You can’t perform that action at this time.
0 commit comments