Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Allow coloring to be forced (useful when we know the output will even…
Browse files Browse the repository at this point in the history
…tually make it's way to a terminal)
  • Loading branch information
natecavanaugh committed Jun 2, 2014
1 parent c50e6a2 commit 5a0ace3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions git-pull-request/git-pull-request.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def color_text(text, token, bold = False):
if options['enable-color'] == True:
color_name = options["color-%s" % token]

if color_name == 'default' or not sys.stdout.isatty():
if color_name == 'default' or (not FORCE_COLOR and not sys.stdout.isatty()):
return text

colors = (
Expand Down Expand Up @@ -1374,7 +1374,7 @@ def update_meta():
def main():
# parse command line options
try:
opts, args = getopt.gnu_getopt(sys.argv[1:], 'hqar:u:l:b:', ['help', 'quiet', 'all', 'repo=', 'reviewer=', 'update', 'no-update', 'user=', 'update-branch=', 'authenticate', 'debug'])
opts, args = getopt.gnu_getopt(sys.argv[1:], 'hqar:u:l:b:', ['help', 'quiet', 'all', 'repo=', 'reviewer=', 'update', 'no-update', 'user=', 'update-branch=', 'authenticate', 'debug', 'force-color'])
except getopt.GetoptError, e:
raise UserWarning("%s\nFor help use --help" % e)

Expand All @@ -1393,10 +1393,11 @@ def main():

global users, DEFAULT_USERNAME
global _work_dir
global DEBUG
global DEBUG, FORCE_COLOR
global auth_username, auth_token

DEBUG = options['debug-mode']
FORCE_COLOR = False

_work_dir = None

Expand Down Expand Up @@ -1449,6 +1450,8 @@ def main():
auth_token = ''
elif o == '--debug':
DEBUG = True
elif o == '--force-color':
FORCE_COLOR = True

if len(username) == 0:
username = raw_input("Github username: ").strip()
Expand Down

0 comments on commit 5a0ace3

Please sign in to comment.