Silicon Heaven CLI access application
Project description
This provides an easy to use CLI interfase to access the SHV network.
Installation
The installation can be done with package manager pip.
$ 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:
> 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.
Example configuration file:
[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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file shvcli-0.6.0.tar.gz
.
File metadata
- Download URL: shvcli-0.6.0.tar.gz
- Upload date:
- Size: 23.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5ff5a9f5846e3334869a730205ac918f1949aeca963a548baa54e6e33ea7c8c |
|
MD5 | 48c81339befd3106a09ae449ff64c0fc |
|
BLAKE2b-256 | 0adc5415fb03b2a035c6a4a7c3ebbe13475c9519d7c9b312e2d63b33c889fd9e |
File details
Details for the file shvcli-0.6.0-py3-none-any.whl
.
File metadata
- Download URL: shvcli-0.6.0-py3-none-any.whl
- Upload date:
- Size: 24.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36a0e537d0f4e6a6674e6482ea3af5085b5049e1c3f4973fe8587a2bb223d9f3 |
|
MD5 | dddecc573e870206bd9507c6a2541d1e |
|
BLAKE2b-256 | d862dece4cc20500eaa6ae5fd95089eb4107a5f12a734a682d2787e5a26538a6 |