Add --nocolor option to forcibly disable output coloring

This commit is contained in:
rdb 2009-11-28 16:01:27 +00:00
parent 3ccc0d4603
commit 2b1f09a032
2 changed files with 6 additions and 1 deletions

View File

@ -103,7 +103,7 @@ def parseopts(args):
global VERSION,COMPRESSOR,THREADCOUNT,OSXTARGET
longopts = [
"help","distributor=","verbose","runtime","osxtarget=",
"optimize=","everything","nothing","installer","rtdist",
"optimize=","everything","nothing","installer","rtdist","nocolor",
"version=","lzma","no-python","threads=","outputdir=","override="]
anything = 0
optimize = ""
@ -125,6 +125,7 @@ def parseopts(args):
elif (option=="--threads"): THREADCOUNT=int(value)
elif (option=="--outputdir"): SetOutputDir(value.strip())
elif (option=="--osxtarget"): OSXTARGET=value.strip()
elif (option=="--nocolor"): DisableColors()
elif (option=="--version"):
VERSION=value
if (len(VERSION.split(".")) != 3): raise "usage"

View File

@ -120,6 +120,10 @@ try:
HAVE_COLORS=sys.stdout.isatty()
except: pass
def DisableColors():
global HAVE_COLORS
HAVE_COLORS = False
def GetColor(color = None):
if not HAVE_COLORS: return ""
if color != None: color = color.lower()