| 1 |
<div align="center"><img src="https://raw.githubusercontent.com/pallets/click/refs/heads/stable/docs/_static/click-name.svg" alt="" height="150"></div> |
| 2 |
|
| 3 |
# Click |
| 4 |
|
| 5 |
Click is a Python package for creating beautiful command line interfaces |
| 6 |
in a composable way with as little code as necessary. It's the "Command |
| 7 |
Line Interface Creation Kit". It's highly configurable but comes with |
| 8 |
sensible defaults out of the box. |
| 9 |
|
| 10 |
It aims to make the process of writing command line tools quick and fun |
| 11 |
while also preventing any frustration caused by the inability to |
| 12 |
implement an intended CLI API. |
| 13 |
|
| 14 |
Click in three points: |
| 15 |
|
| 16 |
- Arbitrary nesting of commands |
| 17 |
- Automatic help page generation |
| 18 |
- Supports lazy loading of subcommands at runtime |
| 19 |
|
| 20 |
|
| 21 |
## A Simple Example |
| 22 |
|
| 23 |
```python |
| 24 |
import click |
| 25 |
|
| 26 |
@click.command() |
| 27 |
@click.option("--count", default=1, help="Number of greetings.") |
| 28 |
@click.option("--name", prompt="Your name", help="The person to greet.") |
| 29 |
def hello(count, name): |
| 30 |
"""Simple program that greets NAME for a total of COUNT times.""" |
| 31 |
for _ in range(count): |
| 32 |
click.echo(f"Hello, {name}!") |
| 33 |
|
| 34 |
if __name__ == '__main__': |
| 35 |
hello() |
| 36 |
``` |
| 37 |
|
| 38 |
``` |
| 39 |
$ python hello.py --count=3 |
| 40 |
Your name: Click |
| 41 |
Hello, Click! |
| 42 |
Hello, Click! |
| 43 |
Hello, Click! |
| 44 |
``` |
| 45 |
|
| 46 |
|
| 47 |
## Donate |
| 48 |
|
| 49 |
The Pallets organization develops and supports Click and other popular |
| 50 |
packages. In order to grow the community of contributors and users, and |
| 51 |
allow the maintainers to devote more time to the projects, [please |
| 52 |
donate today][]. |
| 53 |
|
| 54 |
[please donate today]: https://palletsprojects.com/donate |
| 55 |
|
| 56 |
## Contributing |
| 57 |
|
| 58 |
See our [detailed contributing documentation][contrib] for many ways to |
| 59 |
contribute, including reporting issues, requesting features, asking or answering |
| 60 |
questions, and making PRs. |
| 61 |
|
| 62 |
[contrib]: https://palletsprojects.com/contributing/ |