Skip to main content
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

Release files for jsh 0.3.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jsh 0.3.6
File Size Uploaded
jsh-0.3.6.tar.gz 10.0 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for jsh 0.3.6
File Interpreter ABI Platform
jsh-0.3.6-py3-none-any.whl Python 3 none any Details
jsh-0.3.6-py2-none-any.whl Python 2 none any Details

Total release size: 26.1 kB

Release files / jsh-0.3.6.tar.gz

Download URL jsh-0.3.6.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
9f5f929fbda895f09663b23c12845720d08502e4e95bc5b7be62cb664efe9370
BLAKE2b-256 checksum
How to use checksums
9b9fe0c300dbfff397c4f2758184005f1338f76f055be1b7484b32d2056030a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / jsh-0.3.6-py3-none-any.whl

Download URL jsh-0.3.6-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
73e86421d409e5a30df4954ae89d5d08c8c59bb147387f86d88c9bf3689f313b
BLAKE2b-256 checksum
How to use checksums
6c909a6b47d964f0df63543c0687970cdd7afacfa0bab67c0bf9d79b247979c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / jsh-0.3.6-py2-none-any.whl

Download URL jsh-0.3.6-py2-none-any.whl
Size 8.1 kB
Tags Python 2
SHA-256 checksum
How to use checksums
e2b80492394362f21ffe41c66b787c35c43b9f5edc5d5afcaef667825bd010f8
BLAKE2b-256 checksum
How to use checksums
304ce384eda16643155e998c0dd9a708610679ba24f836bcbd1a557214b87304
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.6 This release

3 release files

0.3.4

3 release files

0.3.3

3 release files

0.3.2

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page