git cl try-results: make color force-able.
Inspiration:
$ watch -n 10 "git cl try-results"
$ watch --color "ls -al --color"
R=nodir@chromium.org,sergiyb@chromium.org
BUG=
Review URL: https://codereview.chromium.org/1799203002
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299291 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/git_cl.py b/git_cl.py
index 87b5acf..a86ac02 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -453,7 +453,7 @@
def pop(title, f, color=None, **kwargs):
"""Pop matching builds from `builds` dict and print them."""
- if not sys.stdout.isatty() or color is None:
+ if not options.color or color is None:
colorize = str
else:
colorize = lambda x: '%s%s%s' % (color, x, Fore.RESET)
@@ -3552,7 +3552,10 @@
group.add_option(
"-p", "--patchset", type=int, help="patchset number if not current.")
group.add_option(
- "--print-master", action='store_true', help="print master name as well")
+ "--print-master", action='store_true', help="print master name as well.")
+ group.add_option(
+ "--color", action='store_true', default=sys.stdout.isatty(),
+ help="force color output, useful when piping output.")
group.add_option(
"--buildbucket-host", default='cr-buildbucket.appspot.com',
help="Host of buildbucket. The default host is %default.")