Bug 1182677 - Support calling a function during mach command dispatch; r=smacleod

This will give us the ability to execute custom code at command dispatch
time. We can use this for global tests before dispatch.

--HG--
extra : commitid : 5vfmSqOis4W
extra : rebase_source : c285b16007c4b604b164d079a275198c8760e480
This commit is contained in:
Gregory Szorc 2015-07-14 13:46:33 -07:00
parent b696aaef57
commit 4121a5645c

View File

@ -61,6 +61,11 @@ class MachRegistrar(object):
if handler.pass_context and not context:
raise Exception('mach command class requires context.')
if context:
prerun = getattr(context, 'pre_dispatch_handler', None)
if prerun:
prerun(context, handler, args=kwargs)
if handler.pass_context:
instance = cls(context)
else: