##// END OF EJS Templates
registrar: switch @command decorator to class...
Yuya Nishihara -
r32338:ec84db23 default
parent child Browse files
Show More
@@ -96,15 +96,14 b' class _funcregistrarbase(object):'
96 """
96 """
97 pass
97 pass
98
98
99 def command(table):
99 class command(_funcregistrarbase):
100 """Returns a function object to be used as a decorator for making commands.
100 """Decorator to register a command function to table
101
101
102 This function receives a command table as its argument. The table should
102 This class receives a command table as its argument. The table should
103 be a dict.
103 be a dict.
104
104
105 The returned function can be used as a decorator for adding commands
105 The created object can be used as a decorator for adding commands to
106 to that command table. This function accepts multiple arguments to define
106 that command table. This accepts multiple arguments to define a command.
107 a command.
108
107
109 The first argument is the command name.
108 The first argument is the command name.
110
109
@@ -126,20 +125,18 b' def command(table):'
126 repository locations. See ``findrepo()``. If a repository is found, it
125 repository locations. See ``findrepo()``. If a repository is found, it
127 will be used.
126 will be used.
128 """
127 """
129 def cmd(name, options=(), synopsis=None, norepo=False, optionalrepo=False,
128
130 inferrepo=False):
129 def _doregister(self, func, name, options=(), synopsis=None,
131 def decorator(func):
130 norepo=False, optionalrepo=False, inferrepo=False):
131 if True:
132 func.norepo = norepo
132 func.norepo = norepo
133 func.optionalrepo = optionalrepo
133 func.optionalrepo = optionalrepo
134 func.inferrepo = inferrepo
134 func.inferrepo = inferrepo
135 if synopsis:
135 if synopsis:
136 table[name] = func, list(options), synopsis
136 self._table[name] = func, list(options), synopsis
137 else:
137 else:
138 table[name] = func, list(options)
138 self._table[name] = func, list(options)
139 return func
139 return func
140 return decorator
141
142 return cmd
143
140
144 class revsetpredicate(_funcregistrarbase):
141 class revsetpredicate(_funcregistrarbase):
145 """Decorator to register revset predicate
142 """Decorator to register revset predicate
General Comments 0
You need to be logged in to leave comments. Login now