move enabled backends option to BaseApplication

This commit is contained in:
Christophe Benz 2010-04-20 18:58:58 +02:00
commit 7a86ddfbb6
2 changed files with 4 additions and 8 deletions

View file

@ -107,9 +107,11 @@ class BaseApplication(object):
def run(klass):
app = klass()
parser = OptionParser('Usage: %prog [options (-h for help)] URL...')
parser.add_option('-b', '--backends', help='what backend(s) to enable (comma separated)')
parser.add_option('-d', '--debug', action='store_true', help='display debug messages')
parser.add_option('-q', '--quiet', action='store_true', help='display only error messages')
parser.add_option('-v', '--verbose', action='store_true', help='display info messages')
app._configure_parser(parser)
app.configure_parser(parser)
app.options, args = parser.parse_args(sys.argv)
if app.options.debug:
@ -122,6 +124,7 @@ class BaseApplication(object):
level = logging.WARNING
log_format = '%(asctime)s:%(levelname)s:%(filename)s:%(lineno)d:%(funcName)s %(message)s'
logging.basicConfig(stream=sys.stdout, level=level, format=log_format)
app.enabled_backends = app.options.backends.split(',') if app.options.backends else None
try:
sys.exit(app.main(args))
except KeyboardInterrupt: