~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Vincent Ladeuil
  • Date: 2011-07-06 09:22:00 UTC
  • mfrom: (6008 +trunk)
  • mto: (6012.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 6013.
  • Revision ID: v.ladeuil+lp@free.fr-20110706092200-7iai2mwzc0sqdsvf
MergingĀ inĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
312
312
 
313
313
    def __init__(self, name, help, registry=None, converter=None,
314
314
        value_switches=False, title=None, enum_switch=True,
315
 
        lazy_registry=None):
 
315
        lazy_registry=None, short_name=None, short_value_switches=None):
316
316
        """
317
317
        Constructor.
318
318
 
328
328
            which takes a value.
329
329
        :param lazy_registry: A tuple of (module name, attribute name) for a
330
330
            registry to be lazily loaded.
 
331
        :param short_name: The short name for the enum switch, if any
 
332
        :param short_value_switches: A dict mapping values to short names
331
333
        """
332
 
        Option.__init__(self, name, help, type=self.convert)
 
334
        Option.__init__(self, name, help, type=self.convert, short_name=short_name)
333
335
        self._registry = registry
334
336
        if registry is None:
335
337
            if lazy_registry is None:
344
346
        self.converter = converter
345
347
        self.value_switches = value_switches
346
348
        self.enum_switch = enum_switch
 
349
        self.short_value_switches = short_value_switches
347
350
        self.title = title
348
351
        if self.title is None:
349
352
            self.title = name
387
390
                    help = optparse.SUPPRESS_HELP
388
391
                else:
389
392
                    help = self.registry.get_help(key)
 
393
                if (self.short_value_switches and
 
394
                    key in self.short_value_switches):
 
395
                    option_strings.append('-%s' %
 
396
                                          self.short_value_switches[key])
390
397
                parser.add_option(action='callback',
391
398
                              callback=self._optparse_value_callback(key),
392
399
                                  help=help,
555
562
_global_option('update')
556
563
_global_registry_option('log-format', "Use specified log format.",
557
564
                        lazy_registry=('bzrlib.log', 'log_formatter_registry'),
558
 
                        value_switches=True, title='Log format')
 
565
                        value_switches=True, title='Log format',
 
566
                        short_value_switches={'short': 'S'})
559
567
_global_option('long', help='Use detailed log format. Same as --log-format long',
560
568
               short_name='l')
561
569
_global_option('short', help='Use moderately short log format. Same as --log-format short')