author | Gregory Szorc <gps@mozilla.com> |
Thu, 05 Sep 2013 15:41:45 -0700 | |
changeset 145789 | 2b3846b0c06ce40658f50a84e79ab931cb82c831 |
parent 145788 | 76634fb95c411f079ec16b427adc788ff1fc5dad |
child 145790 | 1da522b9214b777ec1635418efa8491c8c180fa0 |
push id | 25225 |
push user | emorley@mozilla.com |
push date | Fri, 06 Sep 2013 14:32:11 +0000 |
treeherder | mozilla-central@fff320870b20 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jhammel |
bugs | 912231 |
milestone | 26.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/python/mach/mach/registrar.py +++ b/python/mach/mach/registrar.py @@ -33,11 +33,33 @@ class MachRegistrar(object): def register_settings_provider(self, cls): self.settings_providers.add(cls) def register_category(self, name, title, description, priority=50): self.categories[name] = (title, description, priority) self.commands_by_category[name] = set() + def dispatch(self, name, context=None, **args): + """Dispatch/run a command. + + Commands can use this to call other commands. + """ + + # TODO The logic in this function overlaps with code in + # mach.main.Main._run() and should be consolidated. + handler = self.command_handlers[name] + cls = handler.cls + + if handler.pass_context and not context: + raise Exception('mach command class requires context.') + + if handler.pass_context: + instance = cls(context) + else: + instance = cls() + + fn = getattr(instance, handler.method) + + return fn(**args) or 0 + Registrar = MachRegistrar() -