color: add debugcolor command (issue4094)
authorOlle Lundberg <geek@nerd.sh>
Wed, 12 Feb 2014 01:00:51 +0100
changeset 20455 a2c08adbb86e
parent 20454 47fd57f650e5
child 20456 9a49feb408f3
color: add debugcolor command (issue4094) This patch adds a debugcolor command that prints all colors that the extension knows about.
hgext/color.py
--- a/hgext/color.py	Thu Jan 30 16:47:29 2014 -0800
+++ b/hgext/color.py	Wed Feb 12 01:00:51 2014 +0100
@@ -426,6 +426,16 @@
          _("when to colorize (boolean, always, auto, or never)"),
          _('TYPE')))
 
+def debugcolor(ui, repo, **opts):
+    global _styles
+    _styles = {}
+    for effect in _effects.keys():
+        _styles[effect] = effect
+    ui.write(('colormode: %s\n') % ui._colormode)
+    ui.write(_('available colors:\n'))
+    for label, colors in _styles.items():
+        ui.write(('%s\n') % colors, label=label)
+
 if os.name != 'nt':
     w32effects = None
 else:
@@ -555,3 +565,8 @@
         finally:
             # Explicitly reset original attributes
             _kernel32.SetConsoleTextAttribute(stdout, origattr)
+
+cmdtable = {
+    'debugcolor':
+        (debugcolor, [], ('hg debugcolor'))
+}