1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
Applied-Upstream: commit:0c57ab7d86e89bdc397d8dc5a1792310096259e7
From: Paul Wise <pabs3@bonedaddy.net>
Date: Sat, 22 Mar 2014 14:05:55 +0800
Bug-Debian: https://bugs.debian.org/742207
Subject: [PATCH] Update the handling of colour output for more use-cases.
Disable colours when stdout is not a terminal by default.
Add an option to enable colours when stdout is not a terminal.
--- a/codespell.py
+++ b/codespell.py
@@ -189,9 +189,13 @@
def parse_options(args):
parser = OptionParser(usage=USAGE, version=VERSION)
+ parser.set_defaults(colors = sys.stdout.isatty())
parser.add_option('-d', '--disable-colors',
- action = 'store_true', default = False,
+ action = 'store_false', dest = 'colors',
help = 'Disable colors even when printing to terminal')
+ parser.add_option('-c', '--enable-colors',
+ action = 'store_true', dest = 'colors',
+ help = 'Enable colors even when not printing to terminal')
parser.add_option('-w', '--write-changes',
action = 'store_true', default = False,
help = 'write changes in place if possible')
@@ -480,7 +484,7 @@
build_dict(options.dictionary)
colors = TermColors();
- if options.disable_colors:
+ if not options.colors:
colors.disable()
if options.summary:
|