diff options
| author | Michael Merickel <michael@merickel.org> | 2015-10-11 12:36:25 -0500 |
|---|---|---|
| committer | Michael Merickel <michael@merickel.org> | 2015-10-11 12:36:25 -0500 |
| commit | 803f94d51f5d630a99b9aa2c47f7de40a5d75ea1 (patch) | |
| tree | 5354cf61b243049703d211854fc9f19d48696ef0 /docs | |
| parent | 9b674ffd9a014c0eb2b6cd620164f85ea855e229 (diff) | |
| parent | b932a45f834ae6bdb5850a2c58d1317844b32914 (diff) | |
| download | pyramid-803f94d51f5d630a99b9aa2c47f7de40a5d75ea1.tar.gz pyramid-803f94d51f5d630a99b9aa2c47f7de40a5d75ea1.tar.bz2 pyramid-803f94d51f5d630a99b9aa2c47f7de40a5d75ea1.zip | |
Merge pull request #1891 from sontek/use_entry_points_for_shells
Use entry points for pshell
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/narr/commandline.rst | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/docs/narr/commandline.rst b/docs/narr/commandline.rst index 1fe2d9278..cb0c914d7 100644 --- a/docs/narr/commandline.rst +++ b/docs/narr/commandline.rst @@ -245,7 +245,7 @@ exposed, and the request is configured to generate urls from the host .. code-block:: text $ $VENV/bin/pshell starter/development.ini - Python 2.6.5 (r265:79063, Apr 29 2010, 00:31:32) + Python 2.6.5 (r265:79063, Apr 29 2010, 00:31:32) [GCC 4.4.3] on linux2 Type "help" for more information. @@ -278,16 +278,46 @@ IPython or bpython If you have `IPython <http://en.wikipedia.org/wiki/IPython>`_ and/or `bpython <http://bpython-interpreter.org/>`_ in -the interpreter you use to invoke the ``pshell`` command, ``pshell`` will +the interpreter you use to invoke the ``pshell`` command, ``pshell`` will autodiscover and use the first one found, in this order: -IPython, bpython, standard Python interpreter. However you could -specifically invoke one of your choice with the ``-p choice`` or +IPython, bpython, standard Python interpreter. However you could +specifically invoke one of your choice with the ``-p choice`` or ``--python-shell choice`` option. .. code-block:: text $ $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(): + from ptpython.repl import embed + def PTPShell(banner, **kwargs): + print(banner) + return embed(**kwargs) + + def shell(env, help): + PTPShell(banner=help, locals=env) + + return shell + .. index:: pair: routes; printing single: proutes |
