view aliases.py @ 4:e818160b1856 default tip

Also tested on 5.0.2 (OpenBSD).
author Marc Simpson <marc@0branch.com>
date Sun, 09 Feb 2020 14:06:37 -0800
parents 99746d7b5f75
children
line wrap: on
line source

'''display currently defined aliases

To apply colouring, the following two labels can be set::

  [color]
  alias.name = yellow
  alias.body = green
'''

from mercurial import registrar

cmdtable = {}
command = registrar.command(cmdtable)

testedwith = b'4.5.3 5.0.2 5.3'

@command(b'aliases', [], b'hg aliases')
def aliases(ui, _repo, *_args, **_opts):
    'Print currently defined aliases.'
    width = 0
    aliases = []
    for alias in ui.configitems(b'alias'):
        name, body = alias[0], alias[1]
        width = max(width, len(name))
        aliases.append((name, body))
    for name, body in aliases:
        name_label = ui.label(name.ljust(width), b'alias.name')
        body_label = ui.label(body, b'alias.body')
        ui.write(b'%s  %s\n' % (name_label, body_label))