mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 912231 - Allow mach commands to easily dispatch to other mach commands; r=jhammel
DONTBUILD (NPOTB)
This commit is contained in:
parent
3dec0d4a55
commit
40c7a7023f
@ -38,6 +38,28 @@ class MachRegistrar(object):
|
||||
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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user