Skip to main content

A shell extension for Click

Project description

Incenp.Click-Shell is an extension to click that easily turns your Click-powered Python command-line application into a shell utility. It is built on top of the built in Python cmd module, with modifications to make it work with Click.

Features

  • Adds a “shell” mode with command completion to any Click app.

  • Just a one line change for most click apps.

Usage

Simply replace @click.group with @incenp.click_shell.shell on the root level command:

import click
from incenp.click_shell import shell

# @click.group()  # no longer
@shell(prompt='my-app> ', intro='Starting my app...')
def my_app():
    pass

@my_app.command()
def testcommand():
    click.echo("testcommand is running")

# more commands

if __name__ == '__main__':
    my_app()

When run, you should expect an output like so:

$ python my_app.py
Starting my app...
my-app> testcommand
testcommand is running
my-app>

Using the Incenp.Click-Shell decorator alters the functionality of your program only when the program is called without a subcommand argument. Otherwise, your app will function identically to how it did before.

History

Incenp.Click-Shell is a fork of Clark Perkins’ click-shell, motivated by the lack of recent development in the original project and in particular the lack of support for recent versions of Click, which introduced changes that completely broke the original click-shell.

Incenp.Click-Shell is used in exactly the same way as the original click-shell, the only difference being that the module to import is named incenp.click_shell instead of click_shell.

Importantly, in this fork Python 2 support has been completely removed. If support for Python 2 is important for you, then you may keep using the original click-shell module instead; it won’t work with Click 8, but if you’re using Python 2 you’re stuck with older versions of Click anyway, since Click 8 also dropped support for Python 2.

Copying

Incenp.Click-Shell is distributed under a 3-clause BSD license. The full license is included in the LICENSE file of the source distribution.

Homepage and repository

The project is located at https://github.com/gouttegd/click-shell with the manual at https://incenp.org/dvlpt/click-shell/index.html.

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

incenp.click-shell-2.1.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

incenp.click_shell-2.1.0-py2.py3-none-any.whl (12.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file incenp.click-shell-2.1.0.tar.gz.

File metadata

  • Download URL: incenp.click-shell-2.1.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for incenp.click-shell-2.1.0.tar.gz
Algorithm Hash digest
SHA256 c5c0c6cafdac670c1bb989338b03a93f245aea6ad01768a1b3ed2cbdd842c103
MD5 a7175c6639692fa04867f4b9fb85a0e6
BLAKE2b-256 6d7bc6fd80ecd279c3dbf58a3950c2291f46c826ecd8aa35e38685fcaf290920

See more details on using hashes here.

File details

Details for the file incenp.click_shell-2.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: incenp.click_shell-2.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

File hashes

Hashes for incenp.click_shell-2.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 6243f4b915d6b46f259565d0237bbc72e1c52df79ad308ed8040e06397f9e3ab
MD5 6c762c34623e134865077c178ecdaf88
BLAKE2b-256 141c272f206d989a576886a5b25314001f04008652f3f70c37f87aee6a987f32

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