1 def attr_to_option(variable):
3 Converts Python attribute names to command line options.
5 >>> attr_to_option("foo_bar")
8 return '--' + variable.replace('_', '-')
10 class Controller(object):
12 Simple controller that actually delegates to :class:`optparse.OptionParser`.
14 def __init__(self, dir, schema):
17 def push(self, parser):
18 """Pushes arg schema to :class:`optparse.OptionParser`."""
19 for arg in self.schema.args.values():
20 parser.add_option(attr_to_option(arg.name), dest=arg.name, metavar=arg.type,
21 default=None, help=arg.help)
22 def handle(self, options):
24 Performs post-processing for the options, including throwing
25 errors if not all arguments are specified.
27 self.schema.commit(self.dir)
28 self.schema.load(options)