From f65151caaa96ca66a8c986fe0bed565fbbd0a80b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 25 Jun 2009 09:11:23 -0700 Subject: [PATCH] Add type information to parser for command line arguments --- src/calibre/ebooks/conversion/cli.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/calibre/ebooks/conversion/cli.py b/src/calibre/ebooks/conversion/cli.py index 3a34fa8675..0650fc73e9 100644 --- a/src/calibre/ebooks/conversion/cli.py +++ b/src/calibre/ebooks/conversion/cli.py @@ -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):