Coverage for src / dotbot / plugin.py: 86%

14 statements  

« prev     ^ index     » next       coverage.py v7.12.0, created at 2025-11-29 10:55 -0800

1from typing import Any 

2 

3from dotbot.context import Context 

4from dotbot.messenger import Messenger 

5 

6 

7class Plugin: 

8 """ 

9 Abstract base class for commands that process directives. 

10 """ 

11 

12 _context: Context 

13 _log: Messenger 

14 supports_dry_run: bool = False # plugins must explicitly declare support for dry-run mode 

15 

16 def __init__(self, context: Context): 

17 self._context = context 

18 self._log = Messenger() 

19 

20 def can_handle(self, directive: str) -> bool: 

21 """ 

22 Returns true if the Plugin can handle the directive. 

23 """ 

24 raise NotImplementedError 

25 

26 def handle(self, directive: str, data: Any) -> bool: 

27 """ 

28 Executes the directive. 

29 

30 Returns true if the Plugin successfully handled the directive. 

31 """ 

32 raise NotImplementedError