Skip to main content

Junos-like shell library for Python

Project description

Build Status Code Health Badge Documentation Status Version Badge License Badge

JSH 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 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.

Documentation

Full documentation can be found at RTD.

Installation

Install from PyPI using pip install jsh.

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

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

cli = jsh.JSH(layout)

while True:
    try:
        cli.read_and_execute()
    except jsh.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.JSH, and starts an infinite loop, using the read_and_execute method of the JSH CLI object to interact with the user.

This provides a CLI that looks like the following:

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

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

jsh-0.3.4.tar.gz (5.8 kB view details)

Uploaded Source

Built Distributions

jsh-0.3.4-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

jsh-0.3.4-py2-none-any.whl (7.9 kB view details)

Uploaded Python 2

File details

Details for the file jsh-0.3.4.tar.gz.

File metadata

  • Download URL: jsh-0.3.4.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for jsh-0.3.4.tar.gz
Algorithm Hash digest
SHA256 0f1ee460db44619a98c81723c3e73b2572d2359148d42b403a16340f05d697bc
MD5 6971e2676bbfeb002a84d95a05e35073
BLAKE2b-256 b91158ad80fe32611ac39583290c0762fb9bd22c6ef82747a078c1db7fbc01f7

See more details on using hashes here.

File details

Details for the file jsh-0.3.4-py3-none-any.whl.

File metadata

File hashes

Hashes for jsh-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fae1b1c97f7bbcf35b2b68538d4d47f40bd7ae1d378a920e4e759a51d22167e4
MD5 7ca8cf402490e9c6b361db14411c7f9c
BLAKE2b-256 825ce73980ec35aac53a00da42f39a183e54ec90fbade59a1f2ad2b56dc9a4c5

See more details on using hashes here.

File details

Details for the file jsh-0.3.4-py2-none-any.whl.

File metadata

File hashes

Hashes for jsh-0.3.4-py2-none-any.whl
Algorithm Hash digest
SHA256 b1305a4a48840fd94c6f35426a010ef17cbe63ccdcc18970606cccc9e508a4bc
MD5 e3ab85941b9eea7241e42be9912b1fb9
BLAKE2b-256 0d73094435cd90cd3539ee0ab4ef561db4f78f7f0d6752d11eb39e1e41facf72

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page