Allow --color=html in hb-diff
authorBehdad Esfahbod <behdad@behdad.org>
Sun, 22 Jan 2012 21:07:32 +0000 (16:07 -0500)
committerBehdad Esfahbod <behdad@behdad.org>
Sun, 22 Jan 2012 21:07:32 +0000 (16:07 -0500)
Not that useful right now as we don't escape < and >.  Perhaps
another tool can be added to convert the ANSI output to HTML.

test/shaping/hb-diff
test/shaping/hb_test_tools.py

index c2ee530..29fd119 100755 (executable)
@@ -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]
index b78cdca..4b261c1 100644 (file)
@@ -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 = []):