Browse Source

Add hook for adding shell context processors

Shamelessly taken from justanr's 'some-hooks' branch.. but psst :)
Peter Justin 7 years ago
parent
commit
3c251c1854
2 changed files with 13 additions and 0 deletions
  1. 4 0
      flaskbb/cli/main.py
  2. 9 0
      flaskbb/plugins/spec.py

+ 4 - 0
flaskbb/cli/main.py

@@ -62,6 +62,10 @@ class FlaskBBGroup(FlaskGroup):
                 "Error while loading CLI Plugins",
                 exc_info=traceback.format_exc()
             )
+        else:
+            shell_context_processors = app.pluggy.hook.flaskbb_shell_context()
+            for p in shell_context_processors:
+                app.shell_context_processor(p)
 
     def get_command(self, ctx, name):
         self._load_flaskbb_plugins(ctx)

+ 9 - 0
flaskbb/plugins/spec.py

@@ -69,6 +69,15 @@ def flaskbb_cli(cli):
     """Hook for registering CLI commands."""
 
 
+@spec
+def flaskbb_shell_context():
+    """
+    Hook for registering shell context handlers
+    Expected to return a single callable function that returns a dictionary or
+    iterable of key value pairs.
+    """
+
+
 # Template Hooks
 
 @spec