shvcli


Nameshvcli JSON
Version 0.6.1 PyPI version JSON
download
home_pageNone
SummarySilicon Heaven CLI access application
upload_time2024-10-31 17:39:12
maintainerNone
docs_urlNone
authorElektroline a.s.
requires_python>=3.11
licenseMIT License Copyright (c) 2023 Elektroline a.s. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            =====================================
Silicon Heaven CLI access application
=====================================
.. image:: https://gitlab.com/silicon-heaven/shvcli/-/raw/master/logo.svg
   :align: right
   :height: 128px

This provides an easy to use CLI interfase to access the SHV network.

* `📃 Sources <https://gitlab.com/silicon-heaven/shvcli>`__
* `⁉️ Issue tracker <https://gitlab.com/silicon-heaven/shvcli/-/issues>`__
* `📕 Silicon Heaven protocol documentation <https://silicon-heaven.github.io/shv-doc/>`__


Installation
------------

The installation can be done with package manager ``pip``.

.. code-block:: console

   $ pip install shvcli


Usage
-----

You need to start application ``shvcli``. The first argument is URL specifying
where client should connect to.

After successful connection you will see prompt (``>``) and you can start typing.
Methods can be called with ``PATH:METHOD`` syntax or with just ``METHOD``. You can
use ``PATH:`` for change current path prefix. This prefix is displayed before
prompt and is prefixed to any paths you specify on command line. To return to
the root you need to use absolute path (``/``).

An example of usage:

.. code-block:: console

   > ls
   .app
   > dir
   dir ls lschng
   > .app:
   .app> dir
   dir ls lschng shvVersionMajor shvVersionMinor name version ping
   .app> name
   "pyshvbroker"
   .app> broker:ls
   currentClient client clientInfo
   .app> ls broker
   currentClient client clientInfo
   .app> broker/currentClient:info
   {"clientId":0,"mountPoint":null,"subscriptions":[],"userName":"admin"}
   .app> /:
   >


Configuration file
------------------

Tool reads configuration from files ``/etc/shvcli.ini`` and ``~/.shvcli.ini``.
They are in INI file format and the following sections are supported:

**hosts**: That provides mapping from some name to RPC URL.

**hosts-shell**: That is same as **hosts** with exception that URL is passed
through your local Shell to expand any variables or command substitutions.

**config**: That allows you to set some initial configuration that can be also
switched in runtime. The following options are available:

* **vimode**: If Vi input mode should be used for command line input. The
  default is ``false``.
* **autoget**: Automatically call getter methods and print received values when
  listing nodes and methods (``ls`` and ``dir`` methods special handling).
* **autoprobe**: Completion process benefits from probing of the SHV nodes with
  ``ls`` and ``dir``, and to provide easier usage this can happen automatically
  in background. This is what this option controls. It is ``true`` by default
  but it might not be desirable in some cases, because this can generate a lot
  of hidden traffic.
* **raw**: Controls if ``ls`` and ``dir`` methods are handled in a special way
  as described later in this document. This special handling can be possibly
  decremental if you are trying to debug something specific with these functions
  and this provides a way to call them with any CPON to see what they provide.
  Note that caching and discovery of the nodes will stop working once you are in
  the raw mode and thus you will no longer get the advantage of that. The
  default is ``false``.
* **debug**: Controls if internal debug messages are displayed. These messages
  can give you idea of what shvcli is actually doing behind the wail but it can
  be also overwhelming. The default is ``false``. It is beneficial to disable
  the **autobrobe** once you enable debug because otherwise output on CLI will
  be mangled on completion.
* **cache**: Controls if cache is preserved between invocations. Cache is
  separated based on the connection URL and stored in files in
  ``$XDG_CACHE_HOME/shvcli``. The default is ``true``.
* **call_attempts**: Number of attempts before method call is abandoned and
  timeout is reported. This makes the total time multiple of **call_timeout**.
* **call_timeout**: Timeout in seconds before call attempt is abandoned. Based
  on the **call_attempts** call is attempted again or timeout is reported.
* **autoget_timeout**: Timeout in seconds before call that is part of autoget
  functionality.


Example configuration file:

.. code-block:: ini

   [hosts]
   localhost = tcp://test@localhost?password=test

   [hosts-shell]
   company = tcp://smith@company.example.org?password=$(pass company/shv)

   [config]
   vimode = true


Internal methods
----------------

CLI provides few additional methods that can be called on top of the ones
provided by SHV network. They are all prefixed with ``!`` to clearly distinguish
them. They provide a way to control CLI as well as to get insight into the
environment you are running in.

**subscribe|sub**: Add new subscribe. Shortcut to the call of
``.app/broker/currentClient:subscribe`` that accepts arguments in more convenient
way (you need to use Map if you call that method directly). The argument has
same format such as method calls in this tool, that means ``PATH:METHOD`` where
``METHOD`` can be left out to match all methods. Pattern subscribes are not
supporter, yet.

**unsubscribe|usub**: Unsubscribe existing subscription. It is reverse operation
to the **subscribe** and same remarks apply here as well. It is a shortcut to
the call of ``.app/broker/currentClient:unsubscribe``

**subscriptions|subs**: List current subscriptions. This is shortcut to call
``.app/broker/currentClient:subscriptions``.

**cd**: Change current path prefix to given one even when there is no such node.

**tree|t**: This prints tree of known nodes from current path prefix. This is
not all nodes present in the SHV network. This is only what was discovered so
far (and cached thus it can be also old). You can use it to visualize the tree
of nodes you are working with as well as to get insight into the state of the
cache.

**scan[X]**: Perform recursive probing of the tree up to the depth given as `X`
(the default is 3). On big servers this can be pretty resource demanding and
thus use it sparely.

**set|s**: allows modification of configuration option in runtime.  The names
are the same as in ``config`` section. The boolean options (the only ones
available right now) are set if no argument is provided, or cleared if name is
prefixed with ``no`` (and thus to disable ``raw`` you use ``noraw``). You can
also provide argument ``true`` or ``false``. Without any configuration option it
simply prints the current configuration.


Special methods ``ls`` and ``dir``
----------------------------------

These methods are handled in a special way to allow easy discovery of the SHV
nodes. Their output is processed and displayed in easy to read format but not in
the fullest content.

Their parameter is also handled in a special way. It is considered to be
additional path suffix unless it is a valid CPON. This is allowed to match the
common shells.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "shvcli",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": null,
    "author": "Elektroline a.s.",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/4c/4f/7725f3ce1e2260c1b84a5f8b54fed5a93da7235caece4e1c7ca09f4e9409/shvcli-0.6.1.tar.gz",
    "platform": null,
    "description": "=====================================\nSilicon Heaven CLI access application\n=====================================\n.. image:: https://gitlab.com/silicon-heaven/shvcli/-/raw/master/logo.svg\n   :align: right\n   :height: 128px\n\nThis provides an easy to use CLI interfase to access the SHV network.\n\n* `\ud83d\udcc3 Sources <https://gitlab.com/silicon-heaven/shvcli>`__\n* `\u2049\ufe0f Issue tracker <https://gitlab.com/silicon-heaven/shvcli/-/issues>`__\n* `\ud83d\udcd5 Silicon Heaven protocol documentation <https://silicon-heaven.github.io/shv-doc/>`__\n\n\nInstallation\n------------\n\nThe installation can be done with package manager ``pip``.\n\n.. code-block:: console\n\n   $ pip install shvcli\n\n\nUsage\n-----\n\nYou need to start application ``shvcli``. The first argument is URL specifying\nwhere client should connect to.\n\nAfter successful connection you will see prompt (``>``) and you can start typing.\nMethods can be called with ``PATH:METHOD`` syntax or with just ``METHOD``. You can\nuse ``PATH:`` for change current path prefix. This prefix is displayed before\nprompt and is prefixed to any paths you specify on command line. To return to\nthe root you need to use absolute path (``/``).\n\nAn example of usage:\n\n.. code-block:: console\n\n   > ls\n   .app\n   > dir\n   dir ls lschng\n   > .app:\n   .app> dir\n   dir ls lschng shvVersionMajor shvVersionMinor name version ping\n   .app> name\n   \"pyshvbroker\"\n   .app> broker:ls\n   currentClient client clientInfo\n   .app> ls broker\n   currentClient client clientInfo\n   .app> broker/currentClient:info\n   {\"clientId\":0,\"mountPoint\":null,\"subscriptions\":[],\"userName\":\"admin\"}\n   .app> /:\n   >\n\n\nConfiguration file\n------------------\n\nTool reads configuration from files ``/etc/shvcli.ini`` and ``~/.shvcli.ini``.\nThey are in INI file format and the following sections are supported:\n\n**hosts**: That provides mapping from some name to RPC URL.\n\n**hosts-shell**: That is same as **hosts** with exception that URL is passed\nthrough your local Shell to expand any variables or command substitutions.\n\n**config**: That allows you to set some initial configuration that can be also\nswitched in runtime. The following options are available:\n\n* **vimode**: If Vi input mode should be used for command line input. The\n  default is ``false``.\n* **autoget**: Automatically call getter methods and print received values when\n  listing nodes and methods (``ls`` and ``dir`` methods special handling).\n* **autoprobe**: Completion process benefits from probing of the SHV nodes with\n  ``ls`` and ``dir``, and to provide easier usage this can happen automatically\n  in background. This is what this option controls. It is ``true`` by default\n  but it might not be desirable in some cases, because this can generate a lot\n  of hidden traffic.\n* **raw**: Controls if ``ls`` and ``dir`` methods are handled in a special way\n  as described later in this document. This special handling can be possibly\n  decremental if you are trying to debug something specific with these functions\n  and this provides a way to call them with any CPON to see what they provide.\n  Note that caching and discovery of the nodes will stop working once you are in\n  the raw mode and thus you will no longer get the advantage of that. The\n  default is ``false``.\n* **debug**: Controls if internal debug messages are displayed. These messages\n  can give you idea of what shvcli is actually doing behind the wail but it can\n  be also overwhelming. The default is ``false``. It is beneficial to disable\n  the **autobrobe** once you enable debug because otherwise output on CLI will\n  be mangled on completion.\n* **cache**: Controls if cache is preserved between invocations. Cache is\n  separated based on the connection URL and stored in files in\n  ``$XDG_CACHE_HOME/shvcli``. The default is ``true``.\n* **call_attempts**: Number of attempts before method call is abandoned and\n  timeout is reported. This makes the total time multiple of **call_timeout**.\n* **call_timeout**: Timeout in seconds before call attempt is abandoned. Based\n  on the **call_attempts** call is attempted again or timeout is reported.\n* **autoget_timeout**: Timeout in seconds before call that is part of autoget\n  functionality.\n\n\nExample configuration file:\n\n.. code-block:: ini\n\n   [hosts]\n   localhost = tcp://test@localhost?password=test\n\n   [hosts-shell]\n   company = tcp://smith@company.example.org?password=$(pass company/shv)\n\n   [config]\n   vimode = true\n\n\nInternal methods\n----------------\n\nCLI provides few additional methods that can be called on top of the ones\nprovided by SHV network. They are all prefixed with ``!`` to clearly distinguish\nthem. They provide a way to control CLI as well as to get insight into the\nenvironment you are running in.\n\n**subscribe|sub**: Add new subscribe. Shortcut to the call of\n``.app/broker/currentClient:subscribe`` that accepts arguments in more convenient\nway (you need to use Map if you call that method directly). The argument has\nsame format such as method calls in this tool, that means ``PATH:METHOD`` where\n``METHOD`` can be left out to match all methods. Pattern subscribes are not\nsupporter, yet.\n\n**unsubscribe|usub**: Unsubscribe existing subscription. It is reverse operation\nto the **subscribe** and same remarks apply here as well. It is a shortcut to\nthe call of ``.app/broker/currentClient:unsubscribe``\n\n**subscriptions|subs**: List current subscriptions. This is shortcut to call\n``.app/broker/currentClient:subscriptions``.\n\n**cd**: Change current path prefix to given one even when there is no such node.\n\n**tree|t**: This prints tree of known nodes from current path prefix. This is\nnot all nodes present in the SHV network. This is only what was discovered so\nfar (and cached thus it can be also old). You can use it to visualize the tree\nof nodes you are working with as well as to get insight into the state of the\ncache.\n\n**scan[X]**: Perform recursive probing of the tree up to the depth given as `X`\n(the default is 3). On big servers this can be pretty resource demanding and\nthus use it sparely.\n\n**set|s**: allows modification of configuration option in runtime.  The names\nare the same as in ``config`` section. The boolean options (the only ones\navailable right now) are set if no argument is provided, or cleared if name is\nprefixed with ``no`` (and thus to disable ``raw`` you use ``noraw``). You can\nalso provide argument ``true`` or ``false``. Without any configuration option it\nsimply prints the current configuration.\n\n\nSpecial methods ``ls`` and ``dir``\n----------------------------------\n\nThese methods are handled in a special way to allow easy discovery of the SHV\nnodes. Their output is processed and displayed in easy to read format but not in\nthe fullest content.\n\nTheir parameter is also handled in a special way. It is considered to be\nadditional path suffix unless it is a valid CPON. This is allowed to match the\ncommon shells.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Elektroline a.s.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Silicon Heaven CLI access application",
    "version": "0.6.1",
    "project_urls": {
        "repository": "https://gitlab.com/silicon-heaven/shvcli"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "79183ed7316e4562f1225fd2a0b0abcd6ab55e35cfe72a0b32e990d04204fd29",
                "md5": "18dc57d2d6cbd4813d4cbee20b36cbcb",
                "sha256": "8c17c97da1188c1ae889567e81dc30d7e494f424a2668af59271f1d26316f1da"
            },
            "downloads": -1,
            "filename": "shvcli-0.6.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "18dc57d2d6cbd4813d4cbee20b36cbcb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 24573,
            "upload_time": "2024-10-31T17:39:11",
            "upload_time_iso_8601": "2024-10-31T17:39:11.581007Z",
            "url": "https://files.pythonhosted.org/packages/79/18/3ed7316e4562f1225fd2a0b0abcd6ab55e35cfe72a0b32e990d04204fd29/shvcli-0.6.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4c4f7725f3ce1e2260c1b84a5f8b54fed5a93da7235caece4e1c7ca09f4e9409",
                "md5": "2e39c8d461bcbbd7dccffc3dd18f48b5",
                "sha256": "374e66f8678941a97d7cb8f3a4e030ea18b67287598001d0445bda5558ca292a"
            },
            "downloads": -1,
            "filename": "shvcli-0.6.1.tar.gz",
            "has_sig": false,
            "md5_digest": "2e39c8d461bcbbd7dccffc3dd18f48b5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 23621,
            "upload_time": "2024-10-31T17:39:12",
            "upload_time_iso_8601": "2024-10-31T17:39:12.753605Z",
            "url": "https://files.pythonhosted.org/packages/4c/4f/7725f3ce1e2260c1b84a5f8b54fed5a93da7235caece4e1c7ca09f4e9409/shvcli-0.6.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-31 17:39:12",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "silicon-heaven",
    "gitlab_project": "shvcli",
    "lcname": "shvcli"
}
        
Elapsed time: 0.33684s