make a beautiful click app with rich
Project description
Table of Contents
About The Project
Click the screenshot below to see it in action!
Built With
Getting Started
Installation
pip install click-rich-help
future releases should allow install via conda-forge
conda install -c conda-forge click-rich-help
Usage
The syntax for usage is not much different than click-help-colors on which this project it based.
You apply the class to click
groups or commands like so:
@click.group(
cls=HelpStylesGroup,
headers_style="yellow bold",
options_style="cyan italic",
metavar_style="red bold",
)
def cli():
pass
Note that the general context has changed from help colors to help styles. This was intentionally changed to reflect the addition of other ANSII styles, i.e. bold, italic.
This isn't the only significant change though! Now there is also support for coloring metavars. If no color is specified than they will default to the color of the options.
In addition any string that would usually be passed to click will be parsed by rich
to apply the needed colors in styles.
This means you can use rich syntax in click.option()
decorators as well as in docstrings of commands. For instance, you can have something like below.
import click
from click_rich_help import HelpStylesCommand
@click.command(
cls=HelpStylesCommand,
options_style="italic cyan",
headers_style="bold yellow"
)
@click.option('--count', default=1, help='[red]Number[/red] of greetings.')
@click.option('--name', prompt='Your name',
help='The person to greet.')
def hello(count, name):
"""Simple program that greets [b yellow]NAME[/b yellow] for a total of [b yellow]COUNT[/b yellow] times."""
for x in range(count):
click.echo(f"Hello {name}!")
if __name__ == '__main__':
hello()
If you were to view the --help
of the above command you should see the below output.
To preview the included example module in your own terminal you can use two methods:
W/o click-rich-help
and w/ asciinema
asciinema play https://asciinema.org/a/81psoVhEc6F568fZppb6qKBVb
W/ click-rich-help
and curl
curl -s https://raw.githubusercontent.com/daylinmorgan/click-rich-help/main/scripts/example.sh | bash
You can also run it yourself if you have installed click-rich-help
. Which you should!
python -m click_rich_help.example -h
Contributing
To contribute please utilize poetry
and pre-commit
.
optionally manage python installation with conda
:
conda create -n rich_dev python=3.7 poetry
Then follow the below steps
- Fork the Project
- Install the package and dev dependencies w/poetry(
cd click-rich-help; poetry install
) - Create your Feature Branch (
git checkout -b feat/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feat/AmazingFeature
) - Open a Pull Request
Roadmap
- Integrated example module
- Implement Type checking
- Add option to color all help strings
- CI
- test
- pypi
Contact
Daylin Morgan - @tweetsbydaylin
Project Link: https://github.com/daylinmorgan/click-rich-help
Acknowledgments
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for click_rich_help-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 887f3351847ec0b34170afedbde1c81d9dbf044b0fa417196e0cbe7431b0891c |
|
MD5 | c20b9c8163764a66dbb06534f4fb38c3 |
|
BLAKE2b-256 | e62e4bff405dff27f41cb189b00a3b527df8d56d17523b65c45932353d8f47d7 |