Mercurial > hg-stable
changeset 30300:d44c407a5999
color: add the ability to display configured style to 'debugcolor'
The 'hg debugcolor' command gains a '--style' flag to display all the configured
labels and their styles. This have many benefits:
* discovering documented label,
* checking consistency between label's style,
* showing the actual style of a label.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 03 Nov 2016 15:17:02 +0100 |
parents | bb2dfc0ea5b4 |
children | 0986f225c149 |
files | hgext/color.py |
diffstat | 1 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/color.py Thu Nov 03 15:15:47 2016 +0100 +++ b/hgext/color.py Thu Nov 03 15:17:02 2016 +0100 @@ -536,11 +536,16 @@ _("when to colorize (boolean, always, auto, never, or debug)"), _('TYPE'))) -@command('debugcolor', [], 'hg debugcolor') +@command('debugcolor', + [('', 'style', None, _('show all configured styles'))], + 'hg debugcolor') def debugcolor(ui, repo, **opts): - """show available colors and effects""" + """show available color, effects or style""" ui.write(('color mode: %s\n') % ui._colormode) - return _debugdisplaycolor(ui) + if opts.get('style'): + return _debugdisplaystyle(ui) + else: + return _debugdisplaycolor(ui) def _debugdisplaycolor(ui): global _styles @@ -564,6 +569,18 @@ finally: _styles = oldstyle +def _debugdisplaystyle(ui): + ui.write(_('available style:\n')) + width = max(len(s) for s in _styles) + for label, effects in sorted(_styles.items()): + ui.write('%s' % label, label=label) + if effects: + # 50 + ui.write(': ') + ui.write(' ' * (max(0, width - len(label)))) + ui.write(', '.join(ui.label(e, e) for e in effects.split())) + ui.write('\n') + if os.name != 'nt': w32effects = None else: