Allow --color=html in hb-diff
Not that useful right now as we don't escape < and >. Perhaps another tool can be added to convert the ANSI output to HTML.
This commit is contained in:
parent
71632c96da
commit
e4ccbfe276
|
@ -3,7 +3,7 @@
|
|||
from hb_test_tools import *
|
||||
import sys, os
|
||||
|
||||
colors, sys.argv = Colors.Auto (sys.argv)
|
||||
colors = Colors.Auto (sys.argv)
|
||||
|
||||
if len (sys.argv) != 3:
|
||||
print "usage: %s [--color] file1 file2" % sys.argv[0]
|
||||
|
|
|
@ -18,12 +18,24 @@ class Colors:
|
|||
|
||||
@staticmethod
|
||||
def Auto (argv = [], out = sys.stdout):
|
||||
if "--color" in argv or os.isatty (out.fileno ()):
|
||||
if "--color" in sys.argv[1:]:
|
||||
argv.remove ("--color")
|
||||
return Colors.ANSI, argv
|
||||
if os.isatty (out.fileno ()):
|
||||
color = Colors.ANSI
|
||||
else:
|
||||
return Colors.Null, argv
|
||||
color = Colors.Null
|
||||
if "--color" in argv:
|
||||
argv.remove ("--color")
|
||||
color = Colors.ANSI
|
||||
if "--color=ansi" in argv:
|
||||
argv.remove ("--color=ansi")
|
||||
color = Colors.ANSI
|
||||
if "--color=html" in argv:
|
||||
argv.remove ("--color=html")
|
||||
color = Colors.HTML
|
||||
if "--no-color" in argv:
|
||||
argv.remove ("--no-color")
|
||||
color = Colors.Null
|
||||
return color
|
||||
|
||||
|
||||
@staticmethod
|
||||
def Default (argv = []):
|
||||
|
|
Loading…
Reference in New Issue