~benoit.pierre/bzrtools/colordiff_when_tty

« back to all changes in this revision

Viewing changes to command_classes.py

  • Committer: Benoît Pierre
  • Date: 2008-11-17 20:34:27 UTC
  • Revision ID: benoit.pierre@gmail.com-20081117203427-4mv27d7qbuwnhzjx
Add --color=MODE option to cdiff; MODE can be:
* never: never colorize output
* auto: colorize output if terminal supports it, and STDOUT is a TTY
* always: always colorize ouput (default)

Show diffs side-by-side

added added

removed removed

Lines of Context:
38
38
from bzrlib.errors import BzrCommandError
39
39
import bzrlib.ignores
40
40
from bzrlib.trace import note
41
 
from bzrlib.option import Option
 
41
from bzrlib.option import Option, RegistryOption
42
42
 
43
43
from command import BzrToolsCommand
44
44
 
534
534
    """A color version of bzr's diff"""
535
535
    takes_args = property(lambda x: get_cmd_object('diff').takes_args)
536
536
    takes_options = list(get_cmd_object('diff').takes_options) + [
 
537
        RegistryOption.from_kwargs('color',
 
538
            'Color mode to use.',
 
539
            title='Color Mode', value_switches=False, enum_switch=True,
 
540
            never='Never colorize output.',
 
541
            auto='Only colorize output if terminal supports it and STDOUT is a'
 
542
            ' TTY.',
 
543
            always='Always colorize ouput (default).'),
537
544
        Option('check-style',
538
545
            help='Warn if trailing whitespace or spurious changes have been'
539
546
                 ' added.')]
540
547
 
541
 
    def run(self, check_style=False, *args, **kwargs):
 
548
    def run(self, color='always', check_style=False, *args, **kwargs):
542
549
        from colordiff import colordiff
543
 
        colordiff(check_style, *args, **kwargs)
 
550
        colordiff(color, check_style, *args, **kwargs)
544
551
 
545
552
 
546
553
class cmd_rspush(BzrToolsCommand):