---
title: "asyncclick | pypx"
description: "Composable command line interface toolkit, async fork"
canonical_url: "https://pypx.app/packages/asyncclick"
meta:
  "og:description": "Composable command line interface toolkit, async fork"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_asyncclick%2Cversion_8.4.2.1%2Csummary_~Q29tcG9zYWJsZSBjb21tYW5kIGxpbmUgaW50ZXJmYWNlIHRvb2xraXQsIGFzeW5jIGZvcms%2Clicense_BSD-3-Clause%2Cp_Ii9wYWNrYWdlcy9hc3luY2NsaWNrIg%2Cs_uEqsHuvR6af82M1y.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "asyncclick 8.4.2.1"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_asyncclick%2Cversion_8.4.2.1%2Csummary_~Q29tcG9zYWJsZSBjb21tYW5kIGxpbmUgaW50ZXJmYWNlIHRvb2xraXQsIGFzeW5jIGZvcms%2Clicense_BSD-3-Clause%2Cp_Ii9wYWNrYWdlcy9hc3luY2NsaWNrIg%2Cs_uEqsHuvR6af82M1y.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **asyncclick**

v8.4.2.1

Composable command line interface toolkit, async fork

119 KB Python 3.11+ py3-none-anyBSD-3-Clause1 deps

[** Diff **](https://pypx.app/packages/asyncclick/diff)

`$ uv add asyncclick`

# $ asyncclick\_

Asyncclick is a fork of Click (described below) that works with trio or asyncio.

AsyncClick allows you to seamlessly use async command and subcommand handlers.

# Click

Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary. It's the "Command Line Interface Creation Kit". It's highly configurable but comes with sensible defaults out of the box.

It aims to make the process of writing command line tools quick and fun while also preventing any frustration caused by the inability to implement an intended CLI API.

Click in three points:

- Arbitrary nesting of commands
- Automatic help page generation
- Supports lazy loading of subcommands at runtime

## A Simple Example

```
import asyncclick as click
import anyio

@click.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):
        click.echo(f"Hello, {name}!")
        await anyio.sleep(0.2)

if __name__ == '__main__':
    hello()
    # alternately: anyio.run(hello.main)
```

```
$ python hello.py --count=3
Your name: Click
Hello, Click!
Hello, Click!
Hello, Click!
```

## Differences to Click

This async-ized version of Click is mostly backwards compatible for "normal" use: you can freely mix sync and async versions of your command handlers and callbacks.

Several advanced methods, most notably :meth:`BaseCommand.main`, and :meth:`Context.invoke`, are now asynchronous.

The :meth:`BaseCommand.__call__` alias now invokes the main entry point via `anyio.run`. If you already have an async main program, simply use `await cmd.main()` instead of `cmd()`.

:func:`asyncclick.prompt` is asynchronous and accepts a `blocking` parameter that switches between "doesn't affect your event loop but has unwanted effects when interrupted" (bugfix pending) and "pauses your event loop but is safe to interrupt" with Control-C". The latter is the default until we fix that bug.

You cannot use Click and AsyncClick in the same program. This is not a problem in practice, as replacing `import click` with `import asyncclick as click`, and `from click import ...` with `from asyncclick import ...`, should be all that's required.

### Notable packages supporting asyncclick

- [OpenTelemetry](https://pypi.org/project/opentelemetry-instrumentation-asyncclick/) supports instrumenting asyncclick.

## Donate

The Pallets organization develops and supports Click and other popular packages. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, [please donate today](https://palletsprojects.com/donate).

The AsyncClick fork is maintained by Matthias Urlichs [matthias@urlichs.de](mailto:matthias@urlichs.de).

## Contributing

### Click

See our [detailed contributing documentation](https://palletsprojects.com/contributing/) for many ways to contribute, including reporting issues, requesting features, asking or answering questions, and making PRs.

### AsyncClick

You can file async-specific issues, ideally including a corresponding fix, to the [MoaT/asyncclick](https://github.com/M-o-a-T/asyncclick) repository on github.

#### Testing

If you find a bug, please add a testcase to prevent it from recurring.

In tests, you might wonder why `runner.invoke` is not called asynchronously. The reason is that there are far too many of these calls to modify them all. Thus `tests/conftest.py` contains a monkeypatch that turns this call into a thread that runs this call using `anyio.run`.

## **Details **

<dl>

<dt>Version</dt>
<dd>8.4.2.1</dd>

<dt>License</dt>
<dd>BSD-3-Clause</dd>

<dt>Python</dt>
<dd>&gt;=3.11</dd>

</dl>

## **Links**

- [Source](https://github.com/python-trio/asyncclick/)
- [View on PyPI](https://pypi.org/project/asyncclick/)

## **Release Cadence **

**1**

releases in the past year

avg 86 days between releases

## **Maintainers **

- Matthias Urlichs · [matthias@urlichs.de](mailto:matthias@urlichs.de)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/asyncclick#webpage","@type":"WebPage","description":"Composable command line interface toolkit, async fork","name":"asyncclick","url":"https://pypx.app/packages/asyncclick","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/asyncclick"]}]},{"@id":"https://pypx.app/packages/asyncclick#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Composable command line interface toolkit, async fork","license":"BSD-3-Clause","name":"asyncclick","softwareVersion":"8.4.2.1"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
