mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add type information to parser for command line arguments
This commit is contained in:
parent
e65d1325f8
commit
f65151caaa
@ -70,11 +70,18 @@ def option_recommendation_to_cli_option(add_option, rec):
|
||||
switches.append('--'+opt.long_switch)
|
||||
attrs = dict(dest=opt.name, help=opt.help,
|
||||
choices=opt.choices, default=rec.recommended_value)
|
||||
if opt.long_switch == 'verbose':
|
||||
attrs['action'] = 'count'
|
||||
if isinstance(rec.recommended_value, type(True)):
|
||||
attrs['action'] = 'store_false' if rec.recommended_value else \
|
||||
'store_true'
|
||||
else:
|
||||
if isinstance(rec.recommended_value, int):
|
||||
attrs['type'] = 'int'
|
||||
if isinstance(rec.recommended_value, float):
|
||||
attrs['type'] = 'float'
|
||||
|
||||
if opt.long_switch == 'verbose':
|
||||
attrs['action'] = 'count'
|
||||
attrs.pop('type', '')
|
||||
add_option(Option(*switches, **attrs))
|
||||
|
||||
def add_input_output_options(parser, plumber):
|
||||
|
Loading…
x
Reference in New Issue
Block a user