click-shell
raw JSON → 2.1 verified Mon Apr 27 auth: no python maintenance
An extension to Click that turns your Click app into a shell utility with autocomplete and persistent context. Current version 2.1. Maintenance mode with no recent releases.
pip install click-shell Common errors
error ImportError: cannot import name 'Shell' from 'click_shell' ↓
cause Incorrect import path or missing package installation.
fix
Run 'pip install click-shell' and use 'from click_shell import Shell'.
error TypeError: 'Shell' object is not callable ↓
cause Using @click.group() without cls=Shell, or calling Shell() directly instead of decorating a function.
fix
Use @click.group(cls=Shell) on a function, do not instantiate Shell directly.
error RuntimeError: Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment. ↓
cause Python locale misconfiguration; common on minimal Docker images.
fix
Set environment variable 'LC_ALL=C.UTF-8' or 'LANG=C.UTF-8'.
Warnings
gotcha click-shell does not support Click 8+ fully; may cause import errors with newer Click versions. ↓
fix Pin Click to 7.x or use a fork like click-shell2.
deprecated Library is in maintenance mode; no active development since 2019. ↓
fix Consider migrating to alternative like click-shell2 or prompt_toolkit-based solutions.
gotcha The Shell class requires a click.Group subclass; using a simple click.group() decorator will not work. ↓
fix Always pass cls=Shell to @click.group.
Imports
- Shell wrong
from click_shell.shell import Shellcorrectfrom click_shell import Shell - click_shell wrong
import click.shellcorrectimport click_shell
Quickstart
import click
from click_shell import Shell
@click.group(cls=Shell, prompt='myapp> ', intro='Welcome to myapp shell')
def cli():
pass
@cli.command()
def hello():
click.echo('Hello, world!')
if __name__ == '__main__':
cli()