| 1 |
.. rst-class:: hide-header |
| 2 |
|
| 3 |
Welcome to Click |
| 4 |
================ |
| 5 |
|
| 6 |
.. image:: _static/click-name.svg |
| 7 |
:align: center |
| 8 |
:height: 200px |
| 9 |
|
| 10 |
Click is a Python package for creating beautiful command line interfaces |
| 11 |
in a composable way with as little code as necessary. It's the "Command |
| 12 |
Line Interface Creation Kit". It's highly configurable but comes with |
| 13 |
sensible defaults out of the box. |
| 14 |
|
| 15 |
It aims to make the process of writing command line tools quick and fun |
| 16 |
while also preventing any frustration caused by the inability to implement |
| 17 |
an intended CLI API. |
| 18 |
|
| 19 |
Click in three points: |
| 20 |
|
| 21 |
- arbitrary nesting of commands |
| 22 |
- automatic help page generation |
| 23 |
- supports lazy loading of subcommands at runtime |
| 24 |
|
| 25 |
What does it look like? Here is an example of a simple Click program: |
| 26 |
|
| 27 |
.. click:example:: |
| 28 |
|
| 29 |
import click |
| 30 |
|
| 31 |
@click.command() |
| 32 |
@click.option('--count', default=1, help='Number of greetings.') |
| 33 |
@click.option('--name', prompt='Your name', |
| 34 |
help='The person to greet.') |
| 35 |
def hello(count, name): |
| 36 |
"""Simple program that greets NAME for a total of COUNT times.""" |
| 37 |
for x in range(count): |
| 38 |
click.echo(f"Hello {name}!") |
| 39 |
|
| 40 |
if __name__ == '__main__': |
| 41 |
hello() |
| 42 |
|
| 43 |
And what it looks like when run: |
| 44 |
|
| 45 |
.. click:run:: |
| 46 |
|
| 47 |
invoke(hello, ['--count=3'], prog_name='python hello.py', input='John\n') |
| 48 |
|
| 49 |
It automatically generates nicely formatted help pages: |
| 50 |
|
| 51 |
.. click:run:: |
| 52 |
|
| 53 |
invoke(hello, ['--help'], prog_name='python hello.py') |
| 54 |
|
| 55 |
You can get the library directly from PyPI:: |
| 56 |
|
| 57 |
pip install click |
| 58 |
|
| 59 |
Documentation |
| 60 |
============== |
| 61 |
|
| 62 |
.. toctree:: |
| 63 |
:maxdepth: 2 |
| 64 |
|
| 65 |
faqs |
| 66 |
|
| 67 |
Tutorials |
| 68 |
------------ |
| 69 |
.. toctree:: |
| 70 |
:maxdepth: 1 |
| 71 |
|
| 72 |
quickstart |
| 73 |
virtualenv |
| 74 |
|
| 75 |
How to Guides |
| 76 |
--------------- |
| 77 |
.. toctree:: |
| 78 |
:maxdepth: 1 |
| 79 |
|
| 80 |
entry-points |
| 81 |
setuptools |
| 82 |
standalone-apps |
| 83 |
upgrade-guides |
| 84 |
support-multiple-versions |
| 85 |
|
| 86 |
Conceptual Guides |
| 87 |
------------------- |
| 88 |
.. toctree:: |
| 89 |
:maxdepth: 1 |
| 90 |
|
| 91 |
design-opinions |
| 92 |
why |
| 93 |
click-concepts |
| 94 |
|
| 95 |
General Reference |
| 96 |
-------------------- |
| 97 |
|
| 98 |
.. toctree:: |
| 99 |
:maxdepth: 1 |
| 100 |
|
| 101 |
parameters |
| 102 |
parameter-types |
| 103 |
options |
| 104 |
option-decorators |
| 105 |
arguments |
| 106 |
commands-and-groups |
| 107 |
commands |
| 108 |
documentation |
| 109 |
prompts |
| 110 |
handling-files |
| 111 |
advanced |
| 112 |
complex |
| 113 |
extending-click |
| 114 |
testing |
| 115 |
utils |
| 116 |
shell-completion |
| 117 |
exceptions |
| 118 |
command-line-reference |
| 119 |
unicode-support |
| 120 |
wincmd |
| 121 |
|
| 122 |
API Reference |
| 123 |
------------------- |
| 124 |
|
| 125 |
.. toctree:: |
| 126 |
:maxdepth: 2 |
| 127 |
|
| 128 |
api |
| 129 |
|
| 130 |
About Project |
| 131 |
=============== |
| 132 |
|
| 133 |
* This documentation is structured according to `Diataxis <https://diataxis.fr/>`_ and written with `MyST <https://myst-parser.readthedocs.io/en/latest/>`_ |
| 134 |
|
| 135 |
* `Version Policy <https://palletsprojects.com/versions>`_ |
| 136 |
|
| 137 |
* `Donate <https://palletsprojects.com/donate>`_ |
| 138 |
|
| 139 |
.. toctree:: |
| 140 |
:maxdepth: 1 |
| 141 |
|
| 142 |
contributing |
| 143 |
contrib |
| 144 |
license |
| 145 |
changes |