Commit de7004d4 authored by Adrian Buehlmann's avatar Adrian Buehlmann
Browse files

commands: use a decorator to build table incrementally

this allows to define the table entries near the command functions
parent 62e25c63fb3a
......@@ -1251,3 +1251,18 @@ def commitforceeditor(repo, ctx, subs):
raise util.Abort(_("empty commit message"))
return text
def command(table):
'''returns a function object bound to table which can be used as
a decorator for populating table as a command table'''
def cmd(name, options, synopsis=None):
def decorator(func):
if synopsis:
table[name] = func, options, synopsis
table[name] = func, options
return func
return decorator
return cmd
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment