~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: jml at canonical
  • Date: 2007-03-28 06:52:02 UTC
  • mto: (2376.4.14 lp-bugs)
  • mto: This revision was merged to the branch mainline in revision 2446.
  • Revision ID: jml@canonical.com-20070328065202-1r825jxnabsy31ak
Blackbox-driven --fixes option to commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
205
205
        yield self.name, self.short_name(), argname, self.help
206
206
 
207
207
 
 
208
class ListOption(Option):
 
209
    def add_option(self, parser, short_name):
 
210
        """Add this option to an Optparse parser."""
 
211
        option_strings = ['--%s' % self.name]
 
212
        if short_name is not None:
 
213
            option_strings.append('-%s' % short_name)
 
214
        parser.add_option(action='callback',
 
215
                          callback=self._optparse_callback,
 
216
                          type='string', metavar=self.argname.upper(),
 
217
                          help=self.help, default=[],
 
218
                          *option_strings)
 
219
 
 
220
    def _optparse_callback(self, option, opt, value, parser):
 
221
        getattr(parser.values, self.name).append(self.type(value))
 
222
 
 
223
 
208
224
class RegistryOption(Option):
209
225
    """Option based on a registry
210
226