8c2dc8cbc6
This is useful for plugins like dotbot-if [1] that want to instantiate their own Dispatcher. Previously, the Dispatcher found the set of available plugins on its own, but as ofb5499c7dc5
, this was changed so that plugins are passed in. Given that it has been over two years since this behavior has been broken/changed, reverting to the previous behavior of having the Dispatcher auto-load plugins might not be ideal, which is why this patch instead makes the set of plugins available via the Context for plugins to use. This was reported in the Dotbot repository [2], and earlier in dotbot-if [3]. dotbot-if is currently using a workaround [4] that was originally implemented in dotbot-ifplatform [5]. [1]: https://github.com/wonderbeyond/dotbot-if [2]: https://github.com/anishathalye/dotbot/issues/339 [3]: https://github.com/wonderbeyond/dotbot-if/issues/1 [4]: https://github.com/wonderbeyond/dotbot-if/pull/2 [5]:e35b5c0d71
18 lines
564 B
Python
18 lines
564 B
Python
# https://github.com/anishathalye/dotbot/issues/339
|
|
# plugins should be able to instantiate a Dispatcher with all the plugins
|
|
|
|
import dotbot
|
|
from dotbot.dispatcher import Dispatcher
|
|
|
|
|
|
class Dispatch(dotbot.Plugin):
|
|
def can_handle(self, directive):
|
|
return directive == "dispatch"
|
|
|
|
def handle(self, directive, data):
|
|
dispatcher = Dispatcher(
|
|
base_directory=self._context.base_directory(),
|
|
options=self._context.options(),
|
|
plugins=self._context.plugins(),
|
|
)
|
|
return dispatcher.dispatch(data)
|