{"id":621,"library":"click-repl","title":"Click REPL Plugin","description":"click-repl is a Python library that provides a REPL (Read-Eval-Print Loop) plugin for Click-based command-line applications. It allows users to execute multiple commands in a single interactive session, maintaining a shared context. The current version is 0.3.0, released in June 2023, and it generally follows the release cadence of its upstream dependency, Click.","status":"active","version":"0.3.0","language":"python","source_language":"en","source_url":"https://github.com/untitaker/click-repl","tags":["click","repl","cli","command-line-interface","interactive"],"install":[{"cmd":"pip install click-repl","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for building command-line interfaces.","package":"click","optional":false},{"reason":"Provides the interactive REPL functionality, including history and tab-completion.","package":"prompt_toolkit","optional":false}],"imports":[{"symbol":"register_repl","correct":"from click_repl import register_repl"},{"note":"Used for advanced REPL customization, instead of `register_repl`.","symbol":"repl","correct":"from click_repl import repl"}],"quickstart":{"code":"import click\nfrom click_repl import register_repl\n\n@click.group()\ndef cli():\n    \"\"\"A simple CLI with a REPL.\"\"\"\n    pass\n\n@cli.command()\ndef hello():\n    click.echo(\"Hello from the REPL!\")\n\n@cli.command()\n@click.argument('name')\ndef greet(name):\n    click.echo(f\"Nice to meet you, {name}!\")\n\nif __name__ == '__main__':\n    register_repl(cli)\n    cli()","lang":"python","description":"This quickstart demonstrates how to integrate `click-repl` into a basic Click application. It defines a Click group `cli` with two commands, `hello` and `greet`. The `register_repl(cli)` function adds a 'repl' subcommand to the CLI, enabling an interactive session where `hello` and `greet` can be executed. To run, save as `my_app.py` and execute `python my_app.py repl` in your terminal, then type `hello` or `greet yourname`."},"warnings":[{"fix":"Upgrade to Python 3.6+ or pin `click-repl` to a version compatible with Python 2.x (e.g., `click-repl<0.3.0`).","message":"`click-repl` 0.3.0 dropped support for Python 2.x. Applications running on Python 2 must use an older version (e.g., 0.2.x).","severity":"breaking","affected_versions":"<0.3.0"},{"fix":"Review custom REPL implementations, especially if directly manipulating `prompt_toolkit` internals, to ensure compatibility with `PromptSession`.","message":"In `click-repl` 0.3.0, the internal implementation for the `prompt()` function was changed to use `prompt_toolkit.PromptSession()` instead of `prompt_toolkit.prompt()`. While this fixed an unbound memory usage growth, it might subtly affect highly customized REPL environments that were directly interacting with the internal prompt mechanism.","severity":"breaking","affected_versions":"0.3.0"},{"fix":"Ensure `click-repl` is version 0.2.0 or higher when using Click 8.x or newer. The current version (0.3.0) is compatible.","message":"Older versions of `click-repl` (specifically prior to 0.2.0) were incompatible with Click 8.0.0 due to changes in Click's internal API. Attempting to use `click-repl` 0.1.x with Click 8+ will result in import errors or runtime failures.","severity":"gotcha","affected_versions":"<0.2.0 with Click>=8.0.0"},{"fix":"Be mindful of state stored in `ctx.obj` within the REPL. Explicitly clear or reset relevant data if a fresh state is required for subsequent commands.","message":"When using `click-repl`, the parent context (`ctx.obj`) is reused between subcommands. This is a feature for performance but can be a footgun if you expect a fresh context for each REPL command, potentially leading to stale data or unexpected side effects if not handled carefully.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T16:50:52.930Z","next_check":"2026-06-26T00:00:00.000Z","problems":[{"fix":"Upgrade `click-repl` to version 0.2.0 or newer using `pip install --upgrade click-repl`. Alternatively, downgrade Click to a version below 8.0.0 using `pip install \"click<8.0.0\"`.","cause":"This error occurs because older versions of `click-repl` (prior to 0.2.0) depended on an internal `click._bashcomplete` module, which was removed in Click version 8.0.0.","error":"ModuleNotFoundError: No module named 'click._bashcomplete'"},{"fix":"Ensure that `register_repl()` or `repl()` is called with a `click.Group` instance (e.g., `register_repl(cli)` where `cli` is a `click.Group`) or the context of a group, not a simple `click.Command`.","cause":"The `repl` function (or `register_repl`) expects a `click.Group` object or the context of a `Group` to provide available commands, but it received a `click.Command` object instead.","error":"AttributeError: 'Command' object has no attribute 'commands'"},{"fix":"Upgrade `click-repl` to the latest version to ensure bug fixes related to exception handling are applied. For example: `pip install --upgrade click-repl`.","cause":"When an unknown command is entered in the `click-repl` session, the underlying `click.UsageError` is not always caught and handled gracefully, leading to a traceback.","error":"Unhandled UsageError exception when unsupported command is provided"},{"fix":"Install the `click` package using pip: `pip install click`.","cause":"The `click` library, which `click-repl` depends on, is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'click'"}],"ecosystem":"pypi","meta_description":null,"install_score":100,"install_tag":"verified","quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"0.3.0","install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.51,"mem_mb":13.9,"disk_size":"22.6M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.49,"mem_mb":13.8,"disk_size":"22.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.9,"import_time_s":0.38,"mem_mb":13.9,"disk_size":"23M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.33,"mem_mb":13.8,"disk_size":"23M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.65,"mem_mb":15.6,"disk_size":"25.2M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.69,"mem_mb":15.5,"disk_size":"25.0M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.1,"import_time_s":0.57,"mem_mb":15.6,"disk_size":"26M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.5,"mem_mb":15.5,"disk_size":"26M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.85,"mem_mb":15.6,"disk_size":"16.8M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.81,"mem_mb":15.5,"disk_size":"16.7M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.8,"import_time_s":0.77,"mem_mb":15.6,"disk_size":"17M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.76,"mem_mb":15.5,"disk_size":"17M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.86,"mem_mb":15.6,"disk_size":"16.6M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.8,"mem_mb":15.5,"disk_size":"16.3M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":1.9,"import_time_s":0.77,"mem_mb":15.6,"disk_size":"17M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.77,"mem_mb":15.5,"disk_size":"17M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":null,"import_time_s":0.51,"mem_mb":13.3,"disk_size":"21.9M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.5,"mem_mb":13.1,"disk_size":"21.8M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":" $EXIT -eq 0 ","exit_code":0,"wheel_type":"wheel","failure_reason":null,"install_time_s":2.2,"import_time_s":0.44,"mem_mb":13.3,"disk_size":"22M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":0.39,"mem_mb":13.1,"disk_size":"22M"}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":"stale","tag_description":"widespread failures or data too old to trust","results":[{"runtime":"python:3.10-alpine","exit_code":2},{"runtime":"python:3.10-slim","exit_code":2},{"runtime":"python:3.11-alpine","exit_code":2},{"runtime":"python:3.11-slim","exit_code":2},{"runtime":"python:3.12-alpine","exit_code":2},{"runtime":"python:3.12-slim","exit_code":2},{"runtime":"python:3.13-alpine","exit_code":2},{"runtime":"python:3.13-slim","exit_code":2},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}