asyncclick-repl
Command to make a REPL out of a group by passing -i or --interactive to the cli.
Inspired by click-repl but using native
click command and shell completion.
import asyncio
import asyncclick as click
from asyncclick_repl import AsyncREPL
@click.group(cls=AsyncREPL)
async def cli():
pass
@cli.command()
@click.option("--count", default=1, help="Number of greetings.")
@click.option("--name", prompt="Your name", help="The person to greet.")
async def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for _ in range(count):
await asyncio.sleep(0.1)
click.echo(f"Hello, {name}!")
cli(_anyio_backend="asyncio")
myclickapp -i
> hello --count 2 --name Foo
Hello, Foo!
Hello, Foo!
> :q
Features:
- Tab-completion. Using click's shell completion
- Execute system commands using
!prefix. Note:!should be followed by a space e.g! ls :hshow commands help.
Prompt configuration
Use prompt_kwargs to provide configuration to python-prompt-toolkit's Prompt class
import asyncclick as click
from prompt_toolkit.history import FileHistory
from asyncclick_repl import AsyncREPL
prompt_kwargs = {
"history": FileHistory("./history"),
}
@click.group(cls=AsyncREPL, prompt_kwargs=prompt_kwargs)
async def cli():
pass
cli()
Release files for asyncclick-repl 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asyncclick_repl-0.1.2.tar.gz | 7.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asyncclick_repl-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.0 kB
Release files / asyncclick_repl-0.1.2.tar.gz
| Download URL | asyncclick_repl-0.1.2.tar.gz |
|---|---|
| Size | 7.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a8b724c01864b58c4415e78a83b162d253a335be9865ff1d8536ede8e3fd9d5a
|
|
BLAKE2b-256 checksum How to use checksums |
d9ca8897f9a25657e2491c59582e67956a650a0dc646f350431fc3e8617d835a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / asyncclick_repl-0.1.2-py3-none-any.whl
| Download URL | asyncclick_repl-0.1.2-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5aed90ca75b67eeee8933dbd2c095881ed7d0c5c2fdacbed23d8649d417153e9
|
|
BLAKE2b-256 checksum How to use checksums |
4d32ddb7ed3613b870ab48811271771458c616f6585cb3d1b54d1c2b0ac8ca54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|