jsh-py3


Namejsh-py3 JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/A-c0rN/jsh_py3
SummaryJunos-like shell library for Python 3
upload_time2022-12-06 00:46:17
maintainer
docs_urlNone
authorA-c0rN
requires_python
licenseODbL-1.0
keywords audio sound eas alerting emergency-alert-system
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ==================================================================
jsh_py3 - a Junos-style CLI library, Made for Python3 by fatihusta
==================================================================

**jsh_py3** is a Junos-inspired CLI library for your Python apps.
If you've ever logged into a Junos_ device, you'll know how good the CLI is.
It offers:

- tab-completion, including completion of names of items in the config
- help by pressing "?" at any point
- completion on pressing either space, tab or enter

jsh_py3 attempts to reproduce some of these features (and others) in a Python library
based on Readline, to allow you to build better quality CLIs for your apps.

Installation
============

Install from PyPI using ``pip install jsh_py3``.

Basic Usage
===========

The library takes a CLI "layout", which is a dictionary-based tree structure
describing your CLI commands. For example, a completely useless CLI with
just an ``exit`` command, you would define it like this:

.. code-block:: python

    import jsh_py3

    layout = {
        'exit': jsh_py3.exit,
    }

    jsh_py3.run(layout)

``jsh_py3.run`` is a shortcut for the following:

.. code-block:: python

    cli = jsh_py3.JSH(layout)

    while True:
        try:
            cli.read_and_execute()
        except jsh_py3.JSHError as err:
            print err
        except EOFError:
            break

This creates a basic layout with a single available command (``exit``), passes
it to an instance ``jsh_py3.JSH``, and starts an infinite loop, using the ``read_and_execute``
method of the ``jsh_py3`` CLI object to interact with the user. For more control
over this loop, you should write your own instead of using ``jsh_py3.run``.

This provides a CLI that looks like the following:

::

    > ?
    Possible completions:
      exit
    > ex?
    Possible completions:
      exit
    > exit ?
    Possible completions:
      <[Enter]>   Execute this command
    > exit

.. _Junos: http://www.juniper.net/us/en/products-services/nos/junos/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/A-c0rN/jsh_py3",
    "name": "jsh-py3",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "audio sound eas alerting emergency-alert-system",
    "author": "A-c0rN",
    "author_email": "acrn@gwes-eas.network",
    "download_url": "https://files.pythonhosted.org/packages/1a/6e/0f1a4e5375efd62ccda4878106d1beeb3b4ea80e88c28ee12776e2ea5167/jsh_py3-0.1.0.tar.gz",
    "platform": null,
    "description": "==================================================================\njsh_py3 - a Junos-style CLI library, Made for Python3 by fatihusta\n==================================================================\n\n**jsh_py3** is a Junos-inspired CLI library for your Python apps.\nIf you've ever logged into a Junos_ device, you'll know how good the CLI is.\nIt offers:\n\n- tab-completion, including completion of names of items in the config\n- help by pressing \"?\" at any point\n- completion on pressing either space, tab or enter\n\njsh_py3 attempts to reproduce some of these features (and others) in a Python library\nbased on Readline, to allow you to build better quality CLIs for your apps.\n\nInstallation\n============\n\nInstall from PyPI using ``pip install jsh_py3``.\n\nBasic Usage\n===========\n\nThe library takes a CLI \"layout\", which is a dictionary-based tree structure\ndescribing your CLI commands. For example, a completely useless CLI with\njust an ``exit`` command, you would define it like this:\n\n.. code-block:: python\n\n    import jsh_py3\n\n    layout = {\n        'exit': jsh_py3.exit,\n    }\n\n    jsh_py3.run(layout)\n\n``jsh_py3.run`` is a shortcut for the following:\n\n.. code-block:: python\n\n    cli = jsh_py3.JSH(layout)\n\n    while True:\n        try:\n            cli.read_and_execute()\n        except jsh_py3.JSHError as err:\n            print err\n        except EOFError:\n            break\n\nThis creates a basic layout with a single available command (``exit``), passes\nit to an instance ``jsh_py3.JSH``, and starts an infinite loop, using the ``read_and_execute``\nmethod of the ``jsh_py3`` CLI object to interact with the user. For more control\nover this loop, you should write your own instead of using ``jsh_py3.run``.\n\nThis provides a CLI that looks like the following:\n\n::\n\n    > ?\n    Possible completions:\n      exit\n    > ex?\n    Possible completions:\n      exit\n    > exit ?\n    Possible completions:\n      <[Enter]>   Execute this command\n    > exit\n\n.. _Junos: http://www.juniper.net/us/en/products-services/nos/junos/\n",
    "bugtrack_url": null,
    "license": "ODbL-1.0",
    "summary": "Junos-like shell library for Python 3",
    "version": "0.1.0",
    "split_keywords": [
        "audio",
        "sound",
        "eas",
        "alerting",
        "emergency-alert-system"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "9bec342c7802ffdb9ef55eef6b94a9ab",
                "sha256": "681064717722ec76bce2a1b2c1d89c4dec8ec6f13cb4e9d0a1d155bf808d3855"
            },
            "downloads": -1,
            "filename": "jsh_py3-0.1.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9bec342c7802ffdb9ef55eef6b94a9ab",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 14384,
            "upload_time": "2022-12-06T00:46:16",
            "upload_time_iso_8601": "2022-12-06T00:46:16.190604Z",
            "url": "https://files.pythonhosted.org/packages/fe/a5/68ee054ced5c305dfd41c25cf94411bb39bd758128988326175f1f68f86b/jsh_py3-0.1.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "0d138dfa211c3774af2fbba94809c69d",
                "sha256": "53b21df08a0c6b0564669f8ee254100fcff93789e4427d76f97078e24e2c6b6c"
            },
            "downloads": -1,
            "filename": "jsh_py3-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0d138dfa211c3774af2fbba94809c69d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 13856,
            "upload_time": "2022-12-06T00:46:17",
            "upload_time_iso_8601": "2022-12-06T00:46:17.583001Z",
            "url": "https://files.pythonhosted.org/packages/1a/6e/0f1a4e5375efd62ccda4878106d1beeb3b4ea80e88c28ee12776e2ea5167/jsh_py3-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-06 00:46:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "A-c0rN",
    "github_project": "jsh_py3",
    "lcname": "jsh-py3"
}
        
Elapsed time: 0.01656s