@@ -37,7 +37,10 @@ def __init__(
37
37
self ._exit = exit_on_failure
38
38
39
39
def _setup_context (
40
- self , base_directory : str , options : Optional [Namespace ], plugins : Optional [List [Type [Plugin ]]]
40
+ self ,
41
+ base_directory : str ,
42
+ options : Optional [Namespace ],
43
+ plugins : Optional [List [Type [Plugin ]]],
41
44
) -> None :
42
45
path = os .path .abspath (os .path .expanduser (base_directory ))
43
46
if not os .path .exists (path ):
@@ -62,6 +65,7 @@ def dispatch(self, tasks: List[Dict[str, Any]]) -> bool:
62
65
self ._context .set_defaults (task [action ]) # replace, not update
63
66
handled = True
64
67
# keep going, let other plugins handle this if they want
68
+
65
69
for plugin in self ._plugins :
66
70
if plugin .can_handle (action ):
67
71
try :
@@ -76,14 +80,25 @@ def dispatch(self, tasks: List[Dict[str, Any]]) -> bool:
76
80
self ._log .error (f"An error was encountered while executing action { action } " )
77
81
self ._log .debug (str (err ))
78
82
if self ._exit :
79
- # There was an execption exit
83
+ # There was an exception exit
80
84
return False
85
+
86
+ if action == "plugins" :
87
+ # Create a list of loaded plugin names
88
+ loaded_plugins = [type (plugin ).__name__ for plugin in self ._plugins ]
89
+
90
+ # Load plugins that haven't been loaded yet
91
+ for plugin_subclass in Plugin .__subclasses__ ():
92
+ if type (plugin_subclass ).__name__ not in loaded_plugins :
93
+ self ._plugins .append (plugin_subclass (self ._context ))
94
+
81
95
if not handled :
82
96
success = False
83
97
self ._log .error (f"Action { action } not handled" )
84
98
if self ._exit :
85
99
# Invalid action exit
86
100
return False
101
+
87
102
return success
88
103
89
104
0 commit comments