add the Command.gen_opts option group

Note that commands still have to add the option group to the parser
once they populate it with options (self.parser.add_option_group).
This commit is contained in:
Georgi Valkov 2012-12-10 03:22:28 +02:00
parent 2c09666c31
commit b34feacbf9
2 changed files with 4 additions and 1 deletions

View File

@ -43,6 +43,9 @@ class Command(object):
self.main_parser = main_parser
self.parser = ConfigOptionParser(**parser_kw)
# Commands should add options to this option group
self.cmd_opts = optparse.OptionGroup(self.parser, 'Command Options')
# Re-add all options and option groups.
for group in main_parser.option_groups:
self._copy_option_group(self.parser, group)

View File

@ -23,7 +23,7 @@ class InstallCommand(Command):
super(InstallCommand, self).__init__(*args, **kw)
pypi_opts = optparse.OptionGroup(self.parser, 'Package Index Options')
cmd_opts = optparse.OptionGroup(self.parser, 'Command Options')
cmd_opts = self.cmd_opts
pypi_opts.add_option(
'-f', '--find-links',