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,
}

jsh.run(layout)

jsh.run is a shortcut for the following:

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. For more control over this loop, you should write your own instead of using jsh.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

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.6.tar.gz (10.0 kB view details)

Uploaded Source

Built Distributions

jsh-0.3.6-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

jsh-0.3.6-py2-none-any.whl (8.1 kB view details)

Uploaded Python 2

File details

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

File metadata

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

File hashes

Hashes for jsh-0.3.6.tar.gz
Algorithm Hash digest
SHA256 9f5f929fbda895f09663b23c12845720d08502e4e95bc5b7be62cb664efe9370
MD5 d449584d1e33eee7e8a1d3c80fa51714
BLAKE2b-256 9b9fe0c300dbfff397c4f2758184005f1338f76f055be1b7484b32d2056030a2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jsh-0.3.6-py3-none-any.whl
Algorithm Hash digest
SHA256 73e86421d409e5a30df4954ae89d5d08c8c59bb147387f86d88c9bf3689f313b
MD5 a2a036df57380aaac23f5e0fb37d7c39
BLAKE2b-256 6c909a6b47d964f0df63543c0687970cdd7afacfa0bab67c0bf9d79b247979c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for jsh-0.3.6-py2-none-any.whl
Algorithm Hash digest
SHA256 e2b80492394362f21ffe41c66b787c35c43b9f5edc5d5afcaef667825bd010f8
MD5 48d600ae903b1efe8453636cb2167cc5
BLAKE2b-256 304ce384eda16643155e998c0dd9a708610679ba24f836bcbd1a557214b87304

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