click-repl#
click-repl is an extension for the click module, designed to integrate a REPL
(Read-Eval-Print-Loop) within your click application. It achieves this by utilizing
python-prompt-toolkit as its backend. This module enables seamless
interaction with your CLI commands, providing auto-completion features in your shell environment, and offering a platform to execute
shell commands without the need to tweak your .bashrc or .ps1 configuration files.
All customizations can be conveniently handled using pure Python code.
Installation#
You can install click-repl via pip:
pip install click-repl
Usage#
To add the repl() command to your click app’s main group,
use the register_repl() decorator. Invoke it from command line to start the REPL.
1# filename.py
2
3import click
4from click_repl import register_repl
5
6@register_repl
7@click.group()
8def cli():
9 pass
10
11@cli.command()
12def hello():
13 click.echo("Hello world!")
14
15cli()
Changelog#
v0.3.0#
Uses
PromptSessionclass from prompt_toolkit instead ofprompt()function (#63).Added filter for hidden commands and options (#86).
Added click’s autocompletion support (#88).
Added tab-completion for
PathandBOOLtype arguments (#95).Added ‘expand environmental variables in path’ feature (#96).
Delegate command dispatching to the actual group command.
Updated completer class and tests based on new fix #92 (#102).
Python 3.11 support.
v0.2.0#
Backwards compatibility between click v7 & v8.
Support for click v8 changes.
Update tests to expect hyphens.