asyncclick


Nameasyncclick JSON
Version 8.3.0.7 PyPI version JSON
download
home_pageNone
SummaryComposable command line interface toolkit, async fork
upload_time2025-10-11 08:35:44
maintainerNone
docs_urlNone
authorNone
requires_python>=3.11
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # $ 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.


<div align="center"><img src="https://raw.githubusercontent.com/pallets/click/refs/heads/stable/docs/_static/click-name.svg" alt="" height="150"></div>

# 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

```python
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 asyncronous 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][opentelemetry] supports instrumenting asyncclick.

[opentelemetry]: https://pypi.org/project/opentelemetry-instrumentation-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][].

[please donate today]: https://palletsprojects.com/donate

The AsyncClick fork is maintained by Matthias Urlichs <matthias@urlichs.de>.

## Contributing

### Click

See our [detailed contributing documentation][contrib] for many ways to
contribute, including reporting issues, requesting features, asking or answering
questions, and making PRs.

[contrib]: https://palletsprojects.com/contributing/

### AsyncClick

You can file async-specific issues, ideally including a corresponding fix,
to the [MoaT/asyncclick][moat] repository on github.

[moat]: https://github.com/M-o-a-T/asyncclick

#### 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`.


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "asyncclick",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": "Matthias Urlichs <matthias@urlichs.de>",
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/f9/ca/25e426d16bd0e91c1c9259112cecd17b2c2c239bdd8e5dba430f3bd5e3ef/asyncclick-8.3.0.7.tar.gz",
    "platform": null,
    "description": "# $ asyncclick_\n\nAsyncclick is a fork of Click (described below) that works with trio or asyncio.\n\nAsyncClick allows you to seamlessly use async command and subcommand handlers.\n\n\n<div align=\"center\"><img src=\"https://raw.githubusercontent.com/pallets/click/refs/heads/stable/docs/_static/click-name.svg\" alt=\"\" height=\"150\"></div>\n\n# Click\n\nClick is a Python package for creating beautiful command line interfaces\nin a composable way with as little code as necessary. It's the \"Command\nLine Interface Creation Kit\". It's highly configurable but comes with\nsensible defaults out of the box.\n\nIt aims to make the process of writing command line tools quick and fun\nwhile also preventing any frustration caused by the inability to\nimplement an intended CLI API.\n\nClick in three points:\n\n-   Arbitrary nesting of commands\n-   Automatic help page generation\n-   Supports lazy loading of subcommands at runtime\n\n\n## A Simple Example\n\n```python\nimport asyncclick as click\nimport anyio\n\n@click.command()\n@click.option(\"--count\", default=1, help=\"Number of greetings.\")\n@click.option(\"--name\", prompt=\"Your name\", help=\"The person to greet.\")\nasync def hello(count, name):\n    \"\"\"Simple program that greets NAME for a total of COUNT times.\"\"\"\n    for _ in range(count):\n        click.echo(f\"Hello, {name}!\")\n        await anyio.sleep(0.2)\n\nif __name__ == '__main__':\n    hello()\n    # alternately: anyio.run(hello.main)\n```\n\n```\n$ python hello.py --count=3\nYour name: Click\nHello, Click!\nHello, Click!\nHello, Click!\n```\n\n## Differences to Click\n\nThis async-ized version of Click is mostly backwards compatible for \"normal\" use:\nyou can freely mix sync and async versions of your command handlers and callbacks.\n\nSeveral advanced methods, most notably :meth:`BaseCommand.main`, and\n:meth:`Context.invoke`, are now asynchronous.\n\nThe :meth:`BaseCommand.__call__` alias now invokes the main entry point via\n`anyio.run`. If you already have an async main program, simply use\n``await cmd.main()`` instead of ``cmd()``.\n\n:func:`asyncclick.prompt` is asyncronous and accepts a ``blocking`` parameter\nthat switches between \"doesn't affect your event loop but has unwanted effects when\ninterrupted\" (bugfix pending) and \"pauses your event loop but is safe to interrupt\"\nwith Control-C\". The latter is the default until we fix that bug.\n\nYou cannot use Click and AsyncClick in the same program. This is not a problem\nin practice, as replacing ``import click`` with ``import asyncclick as click``, and\n``from click import ...`` with ``from asyncclick import ...``, should be all that's\nrequired.\n\n### Notable packages supporting asyncclick\n\n* [OpenTelemetry][opentelemetry] supports instrumenting asyncclick.\n\n[opentelemetry]: https://pypi.org/project/opentelemetry-instrumentation-asyncclick/\n\n\n## Donate\n\nThe Pallets organization develops and supports Click and other popular\npackages. In order to grow the community of contributors and users, and\nallow the maintainers to devote more time to the projects, [please\ndonate today][].\n\n[please donate today]: https://palletsprojects.com/donate\n\nThe AsyncClick fork is maintained by Matthias Urlichs <matthias@urlichs.de>.\n\n## Contributing\n\n### Click\n\nSee our [detailed contributing documentation][contrib] for many ways to\ncontribute, including reporting issues, requesting features, asking or answering\nquestions, and making PRs.\n\n[contrib]: https://palletsprojects.com/contributing/\n\n### AsyncClick\n\nYou can file async-specific issues, ideally including a corresponding fix,\nto the [MoaT/asyncclick][moat] repository on github.\n\n[moat]: https://github.com/M-o-a-T/asyncclick\n\n#### Testing\n\nIf you find a bug, please add a testcase to prevent it from recurring.\n\nIn tests, you might wonder why `runner.invoke` is not called asynchronously.\nThe reason is that there are far too many of these calls to modify them all.\nThus ``tests/conftest.py``  contains a monkeypatch that turns this call\ninto a thread that runs this call using `anyio.run`.\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Composable command line interface toolkit, async fork",
    "version": "8.3.0.7",
    "project_urls": {
        "Source": "https://github.com/python-trio/asyncclick/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "01d9782ffcb4c97b889bc12d8276637d2739b99520390ee8fec77c07416c5d12",
                "md5": "242e8b9b5a2e4a8ec0dd3de5da466cfb",
                "sha256": "7607046de39a3f315867cad818849f973e29d350c10d92f251db3ff7600c6c7d"
            },
            "downloads": -1,
            "filename": "asyncclick-8.3.0.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "242e8b9b5a2e4a8ec0dd3de5da466cfb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 109925,
            "upload_time": "2025-10-11T08:35:43",
            "upload_time_iso_8601": "2025-10-11T08:35:43.378865Z",
            "url": "https://files.pythonhosted.org/packages/01/d9/782ffcb4c97b889bc12d8276637d2739b99520390ee8fec77c07416c5d12/asyncclick-8.3.0.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f9ca25e426d16bd0e91c1c9259112cecd17b2c2c239bdd8e5dba430f3bd5e3ef",
                "md5": "9087d387a981ed313cbea4a4b54a13f3",
                "sha256": "8a80d8ac613098ee6a9a8f0248f60c66c273e22402cf3f115ed7f071acfc71d3"
            },
            "downloads": -1,
            "filename": "asyncclick-8.3.0.7.tar.gz",
            "has_sig": false,
            "md5_digest": "9087d387a981ed313cbea4a4b54a13f3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11",
            "size": 277634,
            "upload_time": "2025-10-11T08:35:44",
            "upload_time_iso_8601": "2025-10-11T08:35:44.841678Z",
            "url": "https://files.pythonhosted.org/packages/f9/ca/25e426d16bd0e91c1c9259112cecd17b2c2c239bdd8e5dba430f3bd5e3ef/asyncclick-8.3.0.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-11 08:35:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "python-trio",
    "github_project": "asyncclick",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "asyncclick"
}
        
Elapsed time: 2.98063s