~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/option.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-06-08 13:51:30 UTC
  • mfrom: (5945.1.5 bug38655-short-log)
  • Revision ID: pqm@pqm.ubuntu.com-20110608135130-lmzibvvzxrxwci0t
(vila) Allow -S as shorthand for --log-format=short (Martin von Gagern)

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, short_name=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
334
        Option.__init__(self, name, help, type=self.convert, short_name=short_name)
333
335
        self._registry = registry
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')