Merge branch 'kurtmckee/prevent-source-deletio...'
[dotbot.git] / tests / dotbot_plugin_context_plugin.py
blobd42ca870633754c0743fc3d6000be27525883fcc
1 # https://github.com/anishathalye/dotbot/issues/339
2 # plugins should be able to instantiate a Dispatcher with all the plugins
4 from typing import Any
6 import dotbot
7 from dotbot.dispatcher import Dispatcher
10 class Dispatch(dotbot.Plugin):
11 def can_handle(self, directive: str) -> bool:
12 return directive == "dispatch"
14 def handle(self, directive: str, data: Any) -> bool:
15 if directive != "dispatch":
16 msg = f"Dispatch cannot handle directive {directive}"
17 raise ValueError(msg)
18 dispatcher = Dispatcher(
19 base_directory=self._context.base_directory(),
20 options=self._context.options(),
21 plugins=self._context.plugins(),
23 return dispatcher.dispatch(data)