rich-click


Namerich-click JSON
Version 1.8.0 PyPI version JSON
download
home_pageNone
SummaryFormat click help output nicely with rich
upload_time2024-04-30 02:38:22
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseMIT License Copyright (c) 2022 Phil Ewels Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <p align="center">
    <picture>
        <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ewels/rich-click/main/docs/images/rich-click-logo-darkmode.png">
        <img alt="rich-click logo" src="https://raw.githubusercontent.com/ewels/rich-click/main/docs/images/rich-click-logo.png">
    </picture>
</p>
<p align="center">
    <em>Richly rendered command line interfaces in click.</em>
</p>
<p align="center">
    <img src="https://img.shields.io/pypi/v/rich-click?logo=pypi" alt="PyPI"/>
    <img src="https://github.com/ewels/rich-click/workflows/Test%20Coverage/badge.svg" alt="Test Coverage badge">
    <img src="https://github.com/ewels/rich-click/workflows/Lint%20code/badge.svg" alt="Lint code badge">
</p>

---

<p align="center">
    <a href="https://ewels.github.io/rich-click">Documentation</a>&nbsp&nbspยท&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Source Code</a>&nbsp&nbspยท&nbsp&nbsp<a href="https://github.com/ewels/rich-click">Changelog</a>
</p>

---

**rich-click** is a shim around [Click](https://click.palletsprojects.com/) that renders help output nicely using [Rich](https://github.com/Textualize/rich).

- Click is a _"Python package for creating beautiful command line interfaces"_.
- Rich is a _"Python library for rich text and beautiful formatting in the terminal"_.

The intention of `rich-click` is to provide attractive help output from
Click, formatted with Rich, with minimal customisation required.

## Features

- ๐ŸŒˆ Rich command-line formatting of click help and error messages
- ๐Ÿ˜Œ Same API as Click: usage is simply `import rich_click as click`
- ๐Ÿ’ซ Nice styles by default
- ๐Ÿ’ป CLI tool to run on _other people's_ tools (prefix the command with `rich-click`)
- ๐Ÿ“ฆ Export help text as HTML or SVG
- ๐ŸŽ Group commands and options into named panels
- โŒ Well formatted error messages
- ๐Ÿ”ข Easily give custom sort order for options and commands
- ๐ŸŽจ Extensive customisation of styling and behaviour possible

## Installation

```shell
pip install rich-click
```

[Read the docs](https://ewels.github.io/rich-click#installation) for all supported installation methods.

## Examples

### Simple Example

To use rich-click in your code, replace `import click` with `import rich_click as click` in your existing click CLI:

```python
import rich_click as click

@click.command()
@click.option("--count", default=1, help="Number of greetings.")
@click.option("--name", prompt="Your name", help="The person to greet.")
def hello(count, name):
    """Simple program that greets NAME for a total of COUNT times."""
    for _ in range(count):
        click.echo(f"Hello, {name}!")

if __name__ == '__main__':
    hello()
```

![`python examples/11_hello.py --help`](docs/images/hello.svg)

_Screenshot from [`examples/11_hello.py`](examples/11_hello.py)_

### More complex example

![`python examples/03_groups_sorting.py`](docs/images/command_groups.svg)

_Screenshot from [`examples/03_groups_sorting.py`](examples/03_groups_sorting.py)_

## Usage

This is a quick overview of how to use **rich-click**. [Read the docs](https://ewels.github.io/rich-click) for more information.

There are a couple of ways to begin using `rich-click`:

### Import `rich_click` as `click`

Switch out your normal `click` import with `rich_click`, using the same namespace:

```python
import rich_click as click
```

That's it! โœจ Then continue to use Click as you would normally.

> See [`examples/01_simple.py`](https://github.com/ewels/rich-click/blob/main/examples/01_simple.py) for an example.

### Declarative

If you prefer, you can use `RichGroup` or `RichCommand` with the `cls` argument in your click usage instead.
This means that you can continue to use the unmodified `click` package in parallel.

```python
import click
from rich_click import RichCommand

@click.command(cls=RichCommand)
def main():
    """My amazing tool does all the things."""
```

> See [`examples/02_declarative.py`](https://github.com/ewels/rich-click/blob/main/examples/02_declarative.py) for an example.

### `rich-click` CLI tool

**rich-click** comes with a CLI tool that allows you to format the Click help output from _any_ package that uses Click.

To use, prefix `rich-click` to your normal command.
For example, to get richified Click help text from a package called `awesometool`, you could run:

```console
$ rich-click awesometool --help

Usage: awesometool [OPTIONS]
..more richified output below..
```

## License

This project is licensed under the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rich-click",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "Phil Ewels <phil@ewels.co.uk>, Daniel Reeves <xdanielreeves@gmail.com>",
    "keywords": null,
    "author": null,
    "author_email": "Phil Ewels <phil@ewels.co.uk>",
    "download_url": "https://files.pythonhosted.org/packages/fe/83/3777bb4f23fda6f7388571fff3b5bfe535e29c8c7113f2896d024c801d24/rich_click-1.8.0.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n    <picture>\n        <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/ewels/rich-click/main/docs/images/rich-click-logo-darkmode.png\">\n        <img alt=\"rich-click logo\" src=\"https://raw.githubusercontent.com/ewels/rich-click/main/docs/images/rich-click-logo.png\">\n    </picture>\n</p>\n<p align=\"center\">\n    <em>Richly rendered command line interfaces in click.</em>\n</p>\n<p align=\"center\">\n    <img src=\"https://img.shields.io/pypi/v/rich-click?logo=pypi\" alt=\"PyPI\"/>\n    <img src=\"https://github.com/ewels/rich-click/workflows/Test%20Coverage/badge.svg\" alt=\"Test Coverage badge\">\n    <img src=\"https://github.com/ewels/rich-click/workflows/Lint%20code/badge.svg\" alt=\"Lint code badge\">\n</p>\n\n---\n\n<p align=\"center\">\n    <a href=\"https://ewels.github.io/rich-click\">Documentation</a>&nbsp&nbsp\u00b7&nbsp&nbsp<a href=\"https://github.com/ewels/rich-click\">Source Code</a>&nbsp&nbsp\u00b7&nbsp&nbsp<a href=\"https://github.com/ewels/rich-click\">Changelog</a>\n</p>\n\n---\n\n**rich-click** is a shim around [Click](https://click.palletsprojects.com/) that renders help output nicely using [Rich](https://github.com/Textualize/rich).\n\n- Click is a _\"Python package for creating beautiful command line interfaces\"_.\n- Rich is a _\"Python library for rich text and beautiful formatting in the terminal\"_.\n\nThe intention of `rich-click` is to provide attractive help output from\nClick, formatted with Rich, with minimal customisation required.\n\n## Features\n\n- \ud83c\udf08 Rich command-line formatting of click help and error messages\n- \ud83d\ude0c Same API as Click: usage is simply `import rich_click as click`\n- \ud83d\udcab Nice styles by default\n- \ud83d\udcbb CLI tool to run on _other people's_ tools (prefix the command with `rich-click`)\n- \ud83d\udce6 Export help text as HTML or SVG\n- \ud83c\udf81 Group commands and options into named panels\n- \u274c Well formatted error messages\n- \ud83d\udd22 Easily give custom sort order for options and commands\n- \ud83c\udfa8 Extensive customisation of styling and behaviour possible\n\n## Installation\n\n```shell\npip install rich-click\n```\n\n[Read the docs](https://ewels.github.io/rich-click#installation) for all supported installation methods.\n\n## Examples\n\n### Simple Example\n\nTo use rich-click in your code, replace `import click` with `import rich_click as click` in your existing click CLI:\n\n```python\nimport rich_click as click\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.\")\ndef 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\nif __name__ == '__main__':\n    hello()\n```\n\n![`python examples/11_hello.py --help`](docs/images/hello.svg)\n\n_Screenshot from [`examples/11_hello.py`](examples/11_hello.py)_\n\n### More complex example\n\n![`python examples/03_groups_sorting.py`](docs/images/command_groups.svg)\n\n_Screenshot from [`examples/03_groups_sorting.py`](examples/03_groups_sorting.py)_\n\n## Usage\n\nThis is a quick overview of how to use **rich-click**. [Read the docs](https://ewels.github.io/rich-click) for more information.\n\nThere are a couple of ways to begin using `rich-click`:\n\n### Import `rich_click` as `click`\n\nSwitch out your normal `click` import with `rich_click`, using the same namespace:\n\n```python\nimport rich_click as click\n```\n\nThat's it! \u2728 Then continue to use Click as you would normally.\n\n> See [`examples/01_simple.py`](https://github.com/ewels/rich-click/blob/main/examples/01_simple.py) for an example.\n\n### Declarative\n\nIf you prefer, you can use `RichGroup` or `RichCommand` with the `cls` argument in your click usage instead.\nThis means that you can continue to use the unmodified `click` package in parallel.\n\n```python\nimport click\nfrom rich_click import RichCommand\n\n@click.command(cls=RichCommand)\ndef main():\n    \"\"\"My amazing tool does all the things.\"\"\"\n```\n\n> See [`examples/02_declarative.py`](https://github.com/ewels/rich-click/blob/main/examples/02_declarative.py) for an example.\n\n### `rich-click` CLI tool\n\n**rich-click** comes with a CLI tool that allows you to format the Click help output from _any_ package that uses Click.\n\nTo use, prefix `rich-click` to your normal command.\nFor example, to get richified Click help text from a package called `awesometool`, you could run:\n\n```console\n$ rich-click awesometool --help\n\nUsage: awesometool [OPTIONS]\n..more richified output below..\n```\n\n## License\n\nThis project is licensed under the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2022 Phil Ewels  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Format click help output nicely with rich",
    "version": "1.8.0",
    "project_urls": {
        "Documentation": "https://github.com/ewels/rich-click",
        "Homepage": "https://github.com/ewels/rich-click",
        "Issues": "https://github.com/ewels/rich-click/issues",
        "Repository": "https://github.com/ewels/rich-click"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "92e7de903aff08dafab215b3378a6920b02f3455b7ceeea14843f08b0d99b533",
                "md5": "ea2fc7345a1ece98599ded4a925e0300",
                "sha256": "846f504eb83a948d864888b2d73c71e52c310490c2babceac57e388aead086e2"
            },
            "downloads": -1,
            "filename": "rich_click-1.8.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ea2fc7345a1ece98599ded4a925e0300",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 34632,
            "upload_time": "2024-04-30T02:38:21",
            "upload_time_iso_8601": "2024-04-30T02:38:21.023076Z",
            "url": "https://files.pythonhosted.org/packages/92/e7/de903aff08dafab215b3378a6920b02f3455b7ceeea14843f08b0d99b533/rich_click-1.8.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fe833777bb4f23fda6f7388571fff3b5bfe535e29c8c7113f2896d024c801d24",
                "md5": "6a2c0028eabaac98578cc9b4b54cd61e",
                "sha256": "f8cad0d67d286d6cd6fc9f69f2d6f25c6c4c2d99fb9d6cb3b8987b593dbe6fa8"
            },
            "downloads": -1,
            "filename": "rich_click-1.8.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6a2c0028eabaac98578cc9b4b54cd61e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 37815,
            "upload_time": "2024-04-30T02:38:22",
            "upload_time_iso_8601": "2024-04-30T02:38:22.975320Z",
            "url": "https://files.pythonhosted.org/packages/fe/83/3777bb4f23fda6f7388571fff3b5bfe535e29c8c7113f2896d024c801d24/rich_click-1.8.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-30 02:38:22",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ewels",
    "github_project": "rich-click",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "rich-click"
}
        
Elapsed time: 0.38516s