From cb92023e9d0ddb56d20dcc445a5e028fec581342 Mon Sep 17 00:00:00 2001 From: John Anderson Date: Sun, 6 Sep 2015 15:26:35 -0700 Subject: Use entry points for pshell --- docs/narr/commandline.rst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'docs/narr/commandline.rst') diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index 1fe2d9278..89df13ce4 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -288,6 +288,40 @@ specifically invoke one of your choice with the ``-p choice`` or $ $VENV/bin/pshell -p ipython | bpython | python development.ini#MyProject +Alternative Shells +~~~~~~~~~~~~~~~~~~ +If you want to use a shell that isn't supported out of the box you can introduce +a new shell by registering an entrypoint in your setup.py: + +.. code-block:: python + + setup( + entry_points = """\ + [pyramid.pshell] + myshell=my_app.ptpython_shell_factory + """ + ) + +and then your shell factory should return a function that accepts two arguments, +``env`` and ``help``, this would look like this: + +.. code-block:: python + + def ptpython_shell_factory(): + try: + from ptpython.repl import embed + def PTPShell(banner, **kwargs): + print(banner) + return embed(**kwargs) + except ImportError: + return None + + def shell(env, help): + PTPShell(banner=help, locals=env) + + return shell + + .. index:: pair: routes; printing single: proutes -- cgit v1.2.3