[PATCH 0 of 1] debugcommands.py

Martin Geisler mg at aragost.com
Wed May 11 04:52:03 CDT 2011


Adrian Buehlmann <adrian at cadifra.com> writes:

> Thanks for the hint. Amazing stuff these decorators!

Yeah, they're quite fun :)

> Or (after having pondered
> http://www.artima.com/weblogs/viewpost.jsp?thread=240845 ):
>
> table = {}
>
> class command(object):
>     def __init__(self, name, options, synopsis):
>         self.name = name
>         self.options = options
>         self.synopsis = synopsis
>
>     def __call__(self, func):
>         table[self.name] = (func, self.options, self.synopsis)

We'll also need to copy the __doc__ over.

If we go this route, then maybe this can be combined with the way normal
and shell aliases are created. They are already created as cmdalias
objects in dispatch which are then inserted into commands.table.

-- 
Martin Geisler

aragost Trifork
Professional Mercurial support
http://mercurial.aragost.com/kick-start/


More information about the Mercurial-devel mailing list