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:
import jsh_py3
layout = {
'exit': jsh_py3.exit,
}
jsh_py3.run(layout)
jsh_py3.run is a shortcut for the following:
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
Release files for jsh-py3 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| jsh_py3-0.1.0.tar.gz | 13.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| jsh_py3-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 28.2 kB
Release files / jsh_py3-0.1.0.tar.gz
| Download URL | jsh_py3-0.1.0.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53b21df08a0c6b0564669f8ee254100fcff93789e4427d76f97078e24e2c6b6c
|
|
BLAKE2b-256 checksum How to use checksums |
1a6e0f1a4e5375efd62ccda4878106d1beeb3b4ea80e88c28ee12776e2ea5167
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|
Release files / jsh_py3-0.1.0-py2.py3-none-any.whl
| Download URL | jsh_py3-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 14.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
681064717722ec76bce2a1b2c1d89c4dec8ec6f13cb4e9d0a1d155bf808d3855
|
|
BLAKE2b-256 checksum How to use checksums |
fea568ee054ced5c305dfd41c25cf94411bb39bd758128988326175f1f68f86b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.10.6
|